home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / motiffaq.zip / MOTIFFAQ next >
Text File  |  1993-01-27  |  198KB  |  5,448 lines

  1. Motif FAQ
  2.  
  3. [Last changed: 10 Dec 92]
  4.  
  5. This article contains the answers to some Frequently Asked Questions (FAQ) 
  6. often seen in comp.windows.x.motif. It is posted to help reduce volume in 
  7. this newsgroup and to provide hard-to-find information of general interest.
  8.  
  9.         Please redistribute this article!
  10.  
  11. This FAQ is maintained by Jan Newmarch (jan@ise.canberra.edu.au).  Send
  12. updates and corrections to him at that mail address.  It would help if
  13. the subject line contained the phrase "FAQ".
  14.  
  15. This article includes answers to the following questions. Ones marked with
  16. a + indicate questions new to this issue; those with changes of content since
  17. the last issue are marked by *:
  18.  
  19.  0) TOPIC: WHAT ARE OTHER RELEVANT NEWSGROUPS?
  20.  1) TOPIC: FTP ARCHIVES
  21.  2)* Is the FAQ list available for FTP anywhere?
  22.  3)*  Is this newsgroup accessible via email?
  23.  4) Is this newsgroup archived?
  24.  5) Is the mail list motif-talk archived?
  25.  6) TOPIC: OSF AND MOTIF
  26.  7)*  What versions of Motif are there?
  27.  8)*  Where can I get Motif?
  28.  9) Is there a list of Motif bugs?
  29. 10) Where can I get public domain Motif source?
  30. 11)  Are the Motif examples publically available?
  31. 12)  Has anyone done a public domain Motif lookalike?
  32. 13) Does anyone from OSF pay attention to our questions/suggestions?
  33. 14) Does OSF have an application compliance validation service?  
  34. 15) What is the motif-talk mailing list?
  35. 16) What MIT patches do I use, and when do I use fix-osf?
  36. 17) How does Motif work with X11R5?
  37. 18)  How can I find which version of Motif I have?
  38. 19) TOPIC: LITERATURE
  39. 20)  What books should I read or do I need to program using Motif?
  40. 21) TOPIC: MWM
  41. 22) What is the difference between Motif and mwm?
  42. 23) Does anyone have an alternative set of 3-D defaults for a monochrome screen?
  43. 24)  How can I modify the Motif window manager decorations?
  44. 25)  How can I turn off the Motif window manager functions from the system menu?
  45. 26)  How can tell I if the user has selected the "Close" item on the system menu attached to the top-level shell?
  46. 27)  Is there an mwm virtual desktop manager?
  47. 28) TOPIC: MOTIF GENERATORS
  48. 29)*  What prototyping tools are there to generate Motif code?
  49. 30) TOPIC: TEXT WIDGET
  50. 31) Why does  pressing  <return> in a text widget do nothing?
  51. 32) When I add text to a scrolling text widget how can I get the new text to show?
  52. 33)* Does the text widget support 16 bit character fonts?
  53. 34) How can I stop the text widget from echoing characters typed?
  54. 35) How can I replace characters typed with say a `*'?
  55. 36) How can I best add a large piece of text to a scrolled text widget?
  56. 37) How can I highlight text in the Text widget?
  57. 38)  How can I select all of the text in a widget programmatically?
  58. 39) How can I change colours of text in the Text widget?
  59. 40) How can I change the font of text in the Text widget?
  60. 41) Is there an emacs binding for the text widget?
  61. 42) How can I use a file as the text source for a Text widget?
  62. 43) How can put Text in overstrike mode instead of insert?
  63. 44) How can I make the Delete key do a backspace?
  64. 45) TOPIC: LIST WIDGET
  65. 46) How do I best put a new set of items into a list?
  66. 47)  Can I have strings with different fonts in a list?
  67. 48) Can I get a bitmap to show in a list item like I can in a Label?
  68. 49) Can I have items with different colours in a list?
  69. 50) Can I grey out an item in a list?
  70. 51)  Can I have multi-line items in a list?
  71. 52)+How can I tell the position of selected items in a list?
  72. 53) TOPIC: FILE SELECTION BOX WIDGET
  73. 54) What is libPW.a and do I need it?
  74. 55) What are these compile errors: Undefined symbol _regcmp?
  75. 56) What's wrong with the Motif 1.0 File Selection Box?
  76. 57) TOPIC: FORM WIDGET
  77. 58) Why don't labels in a Form resize when the label is changed?
  78. 59) How can I center a widget in a form?
  79. 60) How do I line up two columns of widgets of different types?
  80. 61) TOPIC: PUSHBUTTON WIDGET
  81. 62) Why can't I use accelerators on buttons not in a menu?
  82. 63) TOPIC: LABEL WIDGET
  83. 64) How can I align the text in a label (button, etc) widget?
  84. 65) Why doesn't label alignment work in a RowColumn?
  85. 66)  How can I set a multiline label?
  86. 67)  How can I have a vertical label?
  87. 68)  How can I have a Pixmap in a Label?
  88. 69) TOPIC: DRAWING AREA WIDGET    
  89. 70) How can I send an expose event to a Drawing Area widget?
  90. 71) How can I know when a DrawingArea has been resized?
  91. 72) TOPIC: MENUS
  92. 73) What can I put inside a menu bar?
  93. 74) Can I have a cascade button without a submenu in a pulldown menu?
  94. 75) Should I have a cascade button without a submenu in a pulldown menu?
  95. 76)  What is the best way to create popup menus?
  96. 77)  How do popup menus work?
  97. 78)  Should I use translation tables or actions for popup menus?
  98. 79)  What are the known bugs in popup menus?
  99. 80)  Can I have multiple popup menus on the same widget?
  100. 81) TOPIC: INPUT FOCUS
  101. 82) How can I direct the keyboard input to a particular widget?
  102. 83)  How can I have a modal dialog which has to be answered before the application can continue?
  103. 84) TOPIC: MEMORY AND SPEED
  104. 85)  Why does my application grow in size?
  105. 86) Why does my application take a long time to start up?
  106. 87) My application is running too slowly. How can I speed it up?
  107. 88) TOPIC: XMSTRING
  108. 89) How can I get the Ascii text out of an XmString?
  109. 90) When can XmStrings used as resources be freed?
  110. 91) Why doesn't XmStringGetNextSegment() work properly?
  111. 92) TOPIC: DIALOGS
  112. 93) How do I stop my dialog disappearing when I press the help button?
  113. 94) How do I make my own dialog?
  114. 95) How come the title bars for my dialogs now have "_popup" or "<-popup" concatenated onto the widget name?
  115. 96) How can I force a dialog window to display?
  116. 97) How can I control placement of a popup widget?
  117. 98) TOPIC: LANGUAGE BINDINGS
  118. 99)*  Is there a C++ binding for Motif?
  119. 100)+ How can I have a C++ member function in a callback?
  120. 101)* Is there a Common Lisp binding for Motif?
  121. 102)  Is there an Ada binding for Motif?
  122. 103) TOPIC: SPECIFIC PLATFORMS
  123. 104) Is it easy to build Motif for a Sun?
  124. 105) What compile errors/warnings might I get in both Sun 3 and Sun 4?
  125. 106) On a Sun 3, what are the mwm startup error messages about?
  126. 107) Are there problems making shared libraries on a Sun?
  127. 108)  The OpenWindows server hangs when I popup a menu with Button 3.
  128. 109) Has anyone made shared libraries on an IBM RS/6000?
  129. 110)  What is the error  "Unaligned access in XmString" under Ultrix?
  130. 111) TOPIC: KEYSYMS
  131. 112)  What is causing the messages "unknown keysym osfDown..."?
  132. 113) What happens if I can't install Motif Keysyms?
  133. 114) Why has OSF introduced Keysyms into Motif 1.1?
  134. 115) TOPIC: ICONS
  135. 116) How can I keep track of changes to iconic/normal window state?
  136. 117) How can I check if my application has come up iconic?
  137. 118) How can I start my application in iconic state?
  138. 119) How can an application iconify itself?
  139. 120) How can an application de-iconify itself?
  140. 121) TOPIC: MISCELLANEOUS
  141. 122)+ What is the matter with Frame in Motif 1.2?
  142. 123)  What is IMUG and how do I join it?
  143. 124)  How do I set the title of a top level window?
  144. 125)  Can I use editres with Motif?
  145. 126)  How can I put decorations on transient windows using olwm?
  146. 127) Why does an augment translation appear to act as replace for some widgets?
  147. 128) How do you "grey" out a widget so that it cannot be activated?
  148. 129) Why doesn't the Help callback work on some widgets?
  149. 130) Where can I get a Table widget?
  150. 131)  Has anyone done a bar graph widget?
  151. 132)  Does anyone know of a source code of a graph widget
  152. 133)  Is there a help system available, such as in Windows 3?
  153. 134) Can I specify a widget in a resource file?
  154. 135) Why are only some of my translations are being installed?
  155. 136)  Where can I get the PanHandler code?
  156. 137) What are these passive grab warnings?
  157. 138) How do I have more buttons than three in a box?
  158. 139)  How do I create a "busy working cursor"?
  159. 140)  What order should the libraries be linked in?
  160. 141)  How do I use xmkmf for Motif clients?
  161. 142)  How do I make context sensitive help?
  162. 143) TOPIC: ACKNOWLEDGEMENTS
  163.  
  164. If you have suggestions or corrections for any of these answers or any 
  165. additional information, please send them directly to jan@ise.canberra.edu.au;
  166. the information will be included in the next revision (or possibly the one 
  167. after that; thanks for the many suggestions which haven't been incorporated 
  168. yet).  The answers in this iteration are acknowledged to be partial.
  169.  
  170. This posting is intended to be distributed at approximately the beginning of 
  171. each month.
  172.  
  173. The information contained herein has been gathered from a variety of sources. In
  174. many cases attribution has been lost; if you would like to claim responsibility
  175. for a particular item, please let us know. 
  176.  
  177. Conventions used below: telephone numbers tend to be Bell-system unless 
  178. otherwise noted; prices on items are not included.
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187. -----------------------------------------------------------------------------
  188. Subject:  0) TOPIC: WHAT ARE OTHER RELEVANT NEWSGROUPS?
  189.  
  190. [Last modified: Dec 92]
  191.  
  192. Answer: This newsgroup is comp.windows.x.motif.  The nearest related group is
  193. comp.windows.x.  It also maintains an FAQ, which deals in all sorts of X, Xlib
  194. and Xt questions. Look there for answers to questions such as "How do I get a
  195. screendump of my application?", "where do I get X11R4", etc.  Other groups
  196. which may have relevant information are comp.windows.x.pex,
  197. comp.windows.x.apps, comp.windows.x.intrinsics, comp.windows.news,
  198. comp.windows.misc and comp.windows.open-look.
  199.  
  200. -----------------------------------------------------------------------------
  201. Subject:  1) TOPIC: FTP ARCHIVES
  202.  
  203. -----------------------------------------------------------------------------
  204. Subject:  2)* Is the FAQ list available for FTP anywhere?
  205.  
  206. [Last modified: November 92]
  207.  
  208. Answer: A number of FAQ's (including this one) are available for anonymous ftp
  209. at pit-manager.mit.edu, 18.172.1.27 under the directory pub/usenet.  (Motif is
  210. under pub/usenet/comp.windows.x.motif) There is also a mail server called
  211. mail-server@pit-manager.mit.edu.  To retrieve a file send mail to the server
  212. with a subject or body similar to
  213.  
  214.         send usenet/comp.windows.x.motif/Frequently_Asked_Questions_About_Motif_(Part_1_of_3)
  215.  
  216. This service is looked after by Jonathan Kamens (jik@pit-manager.mit.edu).
  217.  
  218. It has also been placed in contrib/Motif-FAQ at export.lcs.mit.edu.
  219.  
  220. The FAQ is also available from csc.canberra.edu.au (137.92.1.1) by anonymous
  221. ftp.  It is in the file /pub/motif/Motif-FAQ
  222.  
  223. This files are also accessible from WAIS (Wide Area Information System) under
  224. UC-Motif-FAQ, allowing keyword-based searches of the FAQ.
  225.  
  226. -----------------------------------------------------------------------------
  227. Subject:  3)*  Is this newsgroup accessible via email?
  228.  
  229. [Last modified: December 92]
  230.  
  231. Answer: An email link was maintained by Kee Hinckley. To join, send mail to
  232. motif-request@alfalfa.com or motif-request%alfalfa.com@bu.edu.  However, Kee
  233. has indicated that he doesn't want to do this anymore, and the state of the
  234. mail service is uncertain.
  235.  
  236. -----------------------------------------------------------------------------
  237. Subject:  4) Is this newsgroup archived?
  238.  
  239. [Last modified: November 1992]
  240.  
  241. Answer: The newsgroup files from August 1991 are available from
  242. csc.canberra.edu.au (137.92.1.1) by anonymous ftp.  They are in the directory
  243. /pub/motif/comp.windows.x.motif.
  244.  
  245. These files are also accessible from WAIS (Wide Area Information System) under
  246. comp.windows.x.motif, allowing keyword-based searches of the newsgroup
  247. articles (this time on machine services.canberra.edu.au (137.92.1.12)).
  248.  
  249. -----------------------------------------------------------------------------
  250. Subject:  5) Is the mail list motif-talk archived?
  251.  
  252. Answer: If you have purchased support from OSF then you have access to their
  253. archive server for motif-talk.
  254.  
  255. -----------------------------------------------------------------------------
  256. Subject:  6) TOPIC: OSF AND MOTIF
  257.  
  258. -----------------------------------------------------------------------------
  259. Subject:  7)*  What versions of Motif are there?
  260. [Last modified: November 92]
  261.  
  262. Answer: Motif 1.0 is based on the R3 toolkit.  There are patch releases to
  263. 1.0: 1.0.1, 1.0.A, 1.0.2 and 1.0.3, 1.0.4, 1.0.5. 1.0.A was a fairly major
  264. patch, as it involved a complete re-engineering of UIL and Mrm.  Almost
  265. everyone who has 1.0.x has either 1.0.A or 1.0.3.
  266.  
  267. Motif 1.1 is based on the R4 toolkit.  The intial version was Motif 1.1.0.
  268. Motif 1.1.1 has been released as a patch to licensees with Full Support or
  269. Technical Update service.  Motif 1.1.2 is a patch release which contains the
  270. necessary changes to fix over 80 bugs reported against Motif. It is available
  271. to support contract holders (including both full support and update service).
  272. The 1.1.3 release fixed a further 150 bugs and was available from August 1991
  273. to support contract holders (including both full support and update service).
  274. 1.1.4 offers X11R5 support, but is not an X11R5 product.  1.1.5 was released
  275. in June 92 to licensees who hold a Motif Full Support or Update Support
  276. contract
  277.  
  278. Motif 1.2.0 was released in April 1992 and is based on the X11R5 toolkit.  It
  279. offers increased compatibility with international standards,  PC-style
  280. behavior and binary compatibility with OSF/Motif 1.1 applications.  New
  281. features include drag-and-drop, tear- off menus, toolkit enhancements and new
  282. documentation.  toolkit.  The code is totally ANSI C.  OSF distributes a 10
  283. pages sheet entitled "OSF/Motif R1.1 to R1.2: detailed overview of changes",
  284. which is available from OSF Motif direct channels.  (617-621-7300 or email
  285. direct@osf.org)
  286.  
  287. Motif 1.2.1 was released September 92.  Due to an optimisation from 1.2.0 to
  288. 1.2.1 object code compiled under 1.2.1 (that is, using 1.2.1 header files)
  289. will not link with 1.2.0 libraries (and, very probably, clients that use
  290. shared libraries and are linked against 1.2.1 won't startup against 1.2).
  291.  
  292. From dbrooks@osf.org: "Motif 2.0 will ship well before the sun burns out,
  293. unless we decide to change the name first, and will contain a free plastic
  294. spaceman in every box."
  295.  
  296. -----------------------------------------------------------------------------
  297. Subject:  8)*  Where can I get Motif?
  298.  
  299. [Last modified: November 92]
  300.  
  301. Answer:
  302.     Various hardware vendors produce developer's toolkits of binaries, header
  303. files, and documentation; check your hardware vendor, particularly if that
  304. vendor is an OSF member. Systems known to be shipping now: HP (sans UIL),
  305. Apollo (sans UIL), SCO, ICS, Mips (RISCwindows=X11R3 + full Motif), IBM, Data
  306. General for AViioNs (includes UIL), Bull (?), Concurrent Computer Corporation
  307. 5000, 6000, 8000 series machines, Convex, Sequent.
  308.  
  309.     In addition, independent binary vendors produce Motif toolkits . ICS makes
  310. several binary kits, notably for Sun, DEC, Apple; Quest (408-496-1900) sells
  311. kits for Suns, as well; IXI (+44 223 462 131) offers kits for Sun3 (SunOS 3.5
  312. or later, and Sun4 (SunOS 4.0.1 or later). Unipalm XTech (+44 954211797; or
  313. Aurora Technologies 617-577-1288 in USA) offers a binary kit for Suns based on
  314. Motif 1.1, with shared libraries.  NSL (+33 (1) 43 36 77 50; requests@nsl.fr)
  315. offers kits for the Sun 3 and Sun 4.  [An FAQ is for "personal opinions" on
  316. these toolkits.  I don't think it is appropriate to give such opinions through
  317. this particular posting, so I haven't included any.] In Australia, Information
  318. Technology Consultants Pty Ltd has Motif 1.1.2 for Sun Sparc 4.1 ( phone on
  319. (02) 360 6999, fax on (02) 360 6695 or e-mail to motif@itcsyd.itc.oz.au)
  320. SILOGIC (+33 61.57.95.95), 78 chemin des Sept Deniers - 31200 TOULOUSE FRANCE
  321. sells Motif 1.1 and 1.2 on Sun4 machines. They also provide customers with
  322. Motif maintenance and support, and do consulting on the X window System at
  323. large, including software development.
  324.  
  325.  
  326.  
  327.   The kits include varied levels of bug-fixing and support for shared
  328. libraries.  BIM (Fax : +32(2)759.47.95) offer Motif 1.1 for Sun-3, Sun-4,
  329. Sun-386i. Includes shared libraries.  Metrolink Inc. (+1-305-566-9586,
  330. sales@metrolink.com; in Europe contact ADNT, (33 1) 3956 5333) ships an
  331. implementation of X11R4 and Motif 1.1 for several 386 systems.
  332.  
  333.     An OSF/Motif source license must be obtained from OSF before source can be
  334. obtained from the Open Software Foundation. Call the Direct Channel Desk at
  335. OSF at 617-621-7300 or email direct@osf.org for ordering information.  In
  336. addition to the full Motif source, "option C" allows you to purchase source
  337. for the window manager mwm to run on X terminals.
  338.  
  339.  
  340. -----------------------------------------------------------------------------
  341. Subject:  9) Is there a list of Motif bugs?
  342.  
  343. Answer: With each patch release of Motif shipped, there is a list of known
  344. bugs provided.  The filename on the tape is "./OPENBUGS".  There is also a
  345. list of all the issues closed/resolved in that patch.  That is found as part
  346. of the "./README-1.1.n" (where n is the patch number) file.
  347.  
  348. These are the only OSF published lists.
  349.  
  350. No-one else seems to publish a list.
  351.  
  352.  
  353. -----------------------------------------------------------------------------
  354. Subject: 10) Where can I get public domain Motif source?
  355.  
  356. Answer: You cannot.  Motif source is not publically available.
  357.  
  358.  
  359. -----------------------------------------------------------------------------
  360. Subject: 11)  Are the Motif examples publically available?
  361.  
  362. [Last modified: November 92]
  363.  
  364. Answer: OSF has produced a list of which of the example programs can be
  365. distributed. Call OSF Direct for a copy of it.  Most of the example programs
  366. have been freed from distribution limitations so should be available.
  367.  
  368. In addition to these, many programs on export.lcs.mit.edu in the contrib
  369. directory use Motif.  Source code posted to comp.sources.x often uses Motif.
  370. The examples from Dan Heller's book are on export in
  371. /contrib/OReilly/motif/examples.tar.Z.  The examples from Doug Young's book
  372. are on export in /contrib/young.motif.Z The examples from Thomas Berlages's
  373. book are on export in /contrib/berlage.motif.Z The examples from Donald L.
  374. McMinds's book are on export in /contrib/mastering.motif.tar.Z The examples
  375. from Jan Newmarch's book are export in /contrib/newmarch.tar.Z
  376.  
  377.  
  378.  
  379. -----------------------------------------------------------------------------
  380. Subject: 12)  Has anyone done a public domain Motif lookalike?
  381.  
  382. [Last modified: September 92]
  383.  
  384. Answer: Not yet.  The specification is available (AES), and the validation
  385. suite can be bought, but no-one has taken up the challenge.  There are some
  386. commercial lookalikes (Looking Glass and Neuron Data), but no workalikes.
  387.  
  388. Applications that follow the Style Guide might be certified Motif-compliant
  389. through the checklist process, even though they're not using OSF/Motif
  390. binaries.
  391.  
  392. Tcl is available for ftp from allspice.berkeley.edu, and although implemented
  393. without Xt, is reported to look like Motif.  Strom Sytems (18666 Redmond Way
  394. o-2118, Redmond, WA 98052-6725) have a Simple Toolkit for X-Windows (sic) that
  395. appears to follow the Style Guide even though it doesn't quite look like
  396. Motif.
  397.  
  398. MOOLIT is a USL product that can be runtime switched between the Sun Open Look
  399. and Motif appearance.  It is based on  OLIT 4i.
  400.  
  401.  
  402. -----------------------------------------------------------------------------
  403. Subject: 13) Does anyone from OSF pay attention to our questions/suggestions?
  404.  
  405. Answer: Yes, and they quite often post answers too. But they may not respond
  406. to *your* problem because they have other things to do as well.  This
  407. newsgroup is not run by OSF, and has no formal connection with OSF.  OSF is a
  408. member-driven company.  The membership (and anyone can be a member) provides
  409. the primary input for future development of Motif.
  410.  
  411. -----------------------------------------------------------------------------
  412. Subject: 14) Does OSF have an application compliance validation service?
  413.  
  414. Answer: They have a checklist and a certification process which you can
  415. request from them.  Ask for the Level One Certification Checklist.  The
  416. process is one of self-certification.  It tests only the appearance and
  417. behavior of the application against Motif style.  The product will also be put
  418. in the OSF reference listing.  There's a one-time fee of $250.  According to
  419. the master license agreement, you can't use any OSF identifying mark unless
  420. you have done a certification.
  421.  
  422.  
  423. -----------------------------------------------------------------------------
  424. Subject: 15) What is the motif-talk mailing list?
  425.  
  426. Answer: The motif-talk mailing list is only for those who have purchased a
  427. Motif source code license. You can be placed on this list by emailing to
  428. motif-talk-request@osf.org, citing your Company name and source license
  429. number.
  430.  
  431.  
  432.  
  433. -----------------------------------------------------------------------------
  434. Subject: 16) What MIT patches do I use, and when do I use fix-osf?
  435.  
  436. Answer: The Motif 1.1.0 tape contains MIT patches 1-14. Apply these and any
  437. others you can get.  If your MIT patch level only goes up to fix-16, you also
  438. need to apply fix-osf.  Fix-osf was an emergency patch for a problem that
  439. existed when the Motif 1.1 tape was cut, The MIT fix-17 completely superseded
  440. osf-fix, so if you have applied fix-17 do not apply fix-osf.  The 1.1.1 tape
  441. contains MIT fixes 15-18, as well as an OSF-developed fix that deals with a
  442. subtle bug in the Selection mechanism of the Intrinsics.  Most people will
  443. have fix-15 to 18 by now; if you don't have them:
  444.  
  445.         Back out fix-osf if you have applied it
  446.         Apply fix-15 to 18
  447.         Apply fix-osf-1.1.1
  448.  
  449. The Selection fix was submitted to MIT, who came up with a different fix.  It
  450. will not be made into an R4 fix but should be in R5. The MIT fix was posted to
  451. motif-talk.
  452.  
  453.  
  454. -----------------------------------------------------------------------------
  455. Subject: 17) How does Motif work with X11R5?
  456.  
  457. Answer: Motif 1.1.X is only intended to be built with X11R4.  Motif 1.2.X is
  458. for X11R5.  however, Motif 1.1.4 has been set to also work with X11R5.
  459.  
  460. For Motif 1.1.1, 1.1.2 and 1.1.3 you will need to compile Xlib and Xt with a
  461. MOTIF_BC flag set to YES (page 8, section 3.3 of the R5 release notes), or
  462. you'll also have a link problem (LowerCase) and a fatal run time problem
  463. (XContext manager).  If your applications come up with "Unknown keysym name:
  464. osfActivate" errors, check the variable ProjectRoot. The name
  465. /$PROJECTROOT/lib/XKeysymDB will have been wired into your Xlib.
  466.  
  467. In Motif 1.1.0, XtCallCallback uses NULL as the first argument instead of a
  468. widget ID. This was ok under R4, but must be changed in the source for R5. It
  469. was changed by OSF from Motif 1.1.1 onward.
  470.  
  471. Mrm won't work at all (can't link since it uses an X private variable that has
  472. disappeared in R5).  Thre is an MIT patch that may fix this??  [I confess
  473. ignorance of Mrm and UIL].
  474.  
  475. -----------------------------------------------------------------------------
  476. Subject: 18)  How can I find which version of Motif I have?
  477.  
  478. Answer: The macro XmVERSION gives you the version number.  The macro
  479. XmREVISION gives you the major revision number.  The macro XmVersion combines
  480. these e.g. a value of 1002 is Motif 1.2.
  481.  
  482. To find the minor revision number is not easy.  From Motif 1.1.3 onwards, try
  483. this:
  484.  
  485.    'strings `which mwm` | grep OSF'.
  486.  
  487. to get the full version number e.g. 1.1.3.
  488.  
  489.  
  490. -----------------------------------------------------------------------------
  491. Subject: 19) TOPIC: LITERATURE
  492.  
  493. -----------------------------------------------------------------------------
  494. Subject: 20)  What books should I read or do I need to program using Motif?
  495.  
  496. [Last modified: November 92]
  497.  
  498. Answer: Ken Lee of the DEC Western Software Laboratory (klee@wsl.dec.com)
  499. regularly posts to comp.windows.x and ba.windows.x a list of reference books
  500. and articles on X and X programming.  In FAQ comp.windows.x an extract of his
  501. list appears. Specifically for Motif programming, though:
  502.  
  503. OSF/Motif Programmers Guide, Prentice-Hall 13-640525-8 (Motif 1.0) ISBN 0-13-
  504. 640681-5 (Motif 1.1) (NB: This makes use of the demo programs that you get
  505. with a Motif source license.  The programs are not included and may or may not
  506. be available on your system.)
  507.  
  508. OSF/Motif Programmers Reference Manual, Prentice-Hall 13-640517-17 (Motif 1.0)
  509.  ISBN 0-13-640616-5 (Motif 1.1) You will need this for the system calls.
  510.  
  511. OSF/Motif Style Guide, Prentice-Hall 13-640491-X (Motif 1.0) ISBN 0-13-
  512. 640673-4 (Motif 1.1) You will need this to get some idea of how to write
  513. programs with the correct `look and feel'.
  514.  
  515. You should read at least one of the the non-OSF books on Motif:
  516.  
  517. Young, Doug. "The X Window System: Applications and Programming with Xt (Motif
  518. Version)," Prentice Hall, 1989 (ISBN 0-13-497074-8). The excellent tutorial "X
  519. Window Systems Programming and Applications with Xt," (ISBN 0-13-972167-3)
  520. updated for Motif. [The examples from the Motif version are available on
  521. export in ~ftp/contrib/young.motif.tar.Z]
  522.  
  523. Marshall Brain at brain@adm.csc.ncsu.edu posted a set of simple and useful
  524. Motif tutorials.
  525.  
  526. Berlage, Thomas Berlage, OSF/Motif: Concepts and Programming, Addison-Wesley,
  527. UK, 1991. ISBN 0-201-55792-4.
  528.  
  529. Johnson, Eric F. and Kevin Reichard, Power Programming Motif, MIS: Press,
  530. Portland, OR, 1991. ISBN 1-55828-059-6. Book with disk, ISBN 1-55828-061-8.
  531.  
  532. Heller, Dan, The Motif Programming Manual, Volume 6 of the O'Reilly series on
  533. X.  This is the most complete volume on Motif programming available.  ISBN 0-
  534. 937175-70-6.
  535.  
  536. Barkakati, Nabajyoti, W Window System Programming, SAMS. ISBN 0-672-22750-9.
  537. This contains a section on Motif.
  538.  
  539. Newmarch, Jan, The X Window System and Motif - A Fast Track Approach.
  540. Addison-Wesley, ISBN 0-201-53931-4.
  541.  
  542. You will also need books and references on Xt such as:
  543.  
  544. Asente, Paul J., and Swick, Ralph R., "X Window System Toolkit, The Complete
  545. Programmer's Guide and Specification", Digital Press, 1990.  The bible on Xt.
  546. A treasury of information, excellent and invaluable.  Distributed by Digital
  547. Press, ISBN 1-55558-051-3, order number EY-E757E-DP; and by Prentice- Hall,
  548. ISBN 0-13-972191-6.
  549.  
  550. Nye, Adrian, and Tim O'Reilly, "X Toolkit Programming Manual, Volume 4,"
  551. O'Reilly and Associates, 1989. The folks at O'Reilly give their comprehensive
  552. treatment to programming with the MIT Intrinsics; R4 versions are now
  553. available, as is a Motif 1.1 version (Volume 4M).
  554.  
  555.  
  556. Flanagan, David, ed.,  "X Toolkit Reference Manual, Volume 5," O'Reilly and
  557. Associates, 1992a, Third Edition. A professional reference manual for the MIT
  558. X11R4 and X11R5 Xt.
  559.  
  560. Books and reference manuals on Xlib may also be useful.
  561.  
  562.  
  563.  
  564. -----------------------------------------------------------------------------
  565. Subject: 21) TOPIC: MWM
  566.  
  567. -----------------------------------------------------------------------------
  568. Subject: 22) What is the difference between Motif and mwm?
  569.  
  570. Answer: mwm is a window manager. Motif itself is made up of four parts: a
  571. User-Interface Guideline, an API toolkit of `C' routines which helps in the
  572. building of applications which conform to the Guideline, the window manager
  573. mwm, and a language UIL which is designed to ease user interface development.
  574. In general mwm will run an application built with any X-windows API, and in
  575. general an application built using the Motif toolkit will run under any window
  576. manager.
  577.  
  578.  
  579. -----------------------------------------------------------------------------
  580. Subject: 23) Does anyone have an alternative set of 3-D defaults for a
  581. monochrome screen?
  582.  
  583. Answer: This is obviously a matter of taste. Some alternatives suggested
  584. include
  585.  
  586. !Benjamin Schreiber, bs@osf.osf.org, bs@cs.brandeis.edu
  587. Mwm*foreground:                 black           ! Actually, when a window is
  588. Mwm*background:                 white           ! deactivated, the background
  589. Mwm*backgroundPixmap:           50_foreground   ! becomes white, insted of
  590. Mwm*topShadowPixmap:            white           ! 50% foreground (grey)
  591.  
  592. Mwm*activeForeground:           black
  593. Mwm*activeBackground:           white
  594. Mwm*activeBackgroundPixmap:     50_foreground
  595. Mwm*activeTopShadowPixmap:      white
  596.  
  597. Mwm*menu*backgroundPixmap:      background
  598. Mwm*menu*topShadowPixmap:       50_foreground
  599.  
  600. Mwm*title*foreground:                   black
  601. Mwm*title*background:                   white
  602. Mwm*title*backgroundPixmap:             white
  603. Mwm*title*topShadowPixmap:              50_foreground
  604. Mwm*title*activeForeground:             white
  605. Mwm*title*activeBackground:             black
  606. Mwm*title*activeBackgroundPixmap:       black
  607. Mwm*title*activeBottomShadowPixmap:     50_foreground
  608.  
  609. Mwm*feedback*backgroundPixmap:          white
  610.  
  611. or
  612.  
  613. ! From: tsang@isi.com (Kam C. Tsang)
  614. Mwm*background:                      White
  615. Mwm*activeBackground:                White
  616. Mwm*activeBackgroundPixmap:          25_foreground
  617. Mwm*foreground:                      Black
  618. Mwm*activeForeground:                Black
  619. Mwm*menu*background:                 white
  620. Mwm*menu*foreground:                 black
  621. xterm*Foreground:                    black
  622. xterm*Background:                    white
  623.  
  624.  
  625. or
  626.  
  627. ! From: ucsd.edu!usc!snorkelwacker!paperboy!yee  (Michael K. Yee)
  628. Mwm*cleanText:                          True
  629.  
  630. Mwm*activeBackground:           white
  631. Mwm*activeForeground:           black
  632. Mwm*background:                 white
  633. Mwm*foreground:                 black
  634.  
  635. Mwm*client*activeBackgroundPixmap:      50_foreground
  636. Mwm*client*activeTopShadowPixmap:       foreground
  637. Mwm*client*activeBottomShadowPixmap:    background
  638.  
  639. !Mwm*client*background:                 white
  640. !Mwm*client*foreground:                 black
  641. Mwm*client*backgroundPixmap:            75_foreground
  642. Mwm*client*topShadowPixmap:             foreground
  643. Mwm*client*bottomShadowPixmap:          background
  644.  
  645. !Mwm*feedback*background:               white
  646. !Mwm*feedback*foreground:               black
  647. Mwm*feedback*backgroundPixmap:          50_foreground
  648. !Mwm*feedback*topShadowPixmap:          25_foreground
  649. !Mwm*feedback*bottomShadowPixmap:       background
  650.  
  651. !Mwm*menu*background:                   white
  652. !Mwm*menu*foreground:                   black
  653. Mwm*menu*backgroundPixmap:              foreground
  654. !Mwm*menu*topShadowPixmap:              foreground
  655. !Mwm*menu*bottomShadowPixmap:           background
  656.  
  657. !Mwm*icon*background:                   white
  658. !Mwm*icon*foreground:                   black
  659. Mwm*icon*activeBackgroundPixmap:        50_foreground
  660. Mwm*icon*activeBottomShadowPixmap:      foreground
  661. Mwm*icon*backgroundPixmap:              75_foreground
  662.  
  663.  
  664.  
  665. -----------------------------------------------------------------------------
  666. Subject: 24)  How can I modify the Motif window manager decorations?
  667.  
  668. Answer: In resource files, use the window manager's client resource (which is
  669. the application) and the resource clientDecoration:
  670.  
  671. Mwm*XClock.clientDecoration:   none
  672.  
  673. turns off all clock decorations.  See the mwm(1) entry for other
  674. possibilities.
  675.  
  676. Programmatically, set the VendorShell resource XmNmwmDecorations to
  677. appropriate values: MWM_DECOR_NONE (or a bitwise or of values).
  678.  
  679. -----------------------------------------------------------------------------
  680. Subject: 25)  How can I turn off the Motif window manager functions from the
  681. system menu?
  682. [Last modified: October 92]
  683.  
  684. Answer: The user of an application can control functions in the system menu
  685. for an application using the mwm resource clientFunctions:
  686.  
  687.         mwm.application_name.clientFunctions: -resize -close
  688.  
  689. Note that mwm will have to be restarted after putting this in their resource
  690. database.
  691.  
  692.  
  693. Answer: The writer of an application can only remove items.  Be warned that
  694. your users will probably gnash their teeth, swear furiously at your product
  695. and stop using it if they discover that you have done this.  (Especially if
  696. you have removed the Close button, your application has hung and it has taken
  697. up all of memory and swap so it can't be killed.) Much better is to catch the
  698. action gracefully as in the next question.
  699.  
  700.         #include <Xm/MwmUtil.h>
  701.  
  702.         XtVaGetValues(shell, XmNmwmFunctions, &int_val, NULL);
  703.         int_val &= ~(MWM_FUNC_CLOSE | MWM_FUNC_ALL);
  704.         XtVaSetValues(shell, XmNmwmFunctions, int_val, NULL);
  705.  
  706.  
  707.  
  708. -----------------------------------------------------------------------------
  709. Subject: 26)  How can tell I if the user has selected the "Close" item on the
  710. system menu attached to the top-level shell?  I need to do some clean up
  711. before exiting.
  712.  
  713. Answer:          This works with R4 Intrinsics
  714.  
  715.         void FinalCleanupCB(w, client_data, call_data)
  716.         Widget   w;
  717.         caddr_t  client_data, call_data;
  718.         {
  719.                 /* tidy up stuff here */
  720.                 ...
  721.                 /* exit if you want to */
  722.                 exit (0);
  723.         }
  724.  
  725.         main()
  726.         {
  727.                 Atom wm_delete_window;
  728.  
  729.                 ...
  730.                 XtRealizeWidget(toplevel);
  731.                 ...
  732.                 wm_delete_window =
  733.                         XmInternAtom(XtDisplay(toplevel),
  734.                                 "WM_DELETE_WINDOW", False);
  735.                 XmAddWMProtocolCallback(toplevel, wm_delete_window,
  736.                         FinalCleanupCB, NULL);
  737.                 XtMainLoop();
  738.         }
  739.  
  740. This will still kill the application.  To turn this behaviour off so that the
  741. application is not killed, set the shell resource XmNdeleteResponse to
  742. XmDO_NOTHING.  This means that users cannot kill your application via the
  743. system menu, and may be a bad thing.
  744.  
  745. If you are running R3, Bob Hays (bobhays@spss.com) has suggested this:
  746. "Trapping on the delete window atom does not work as I cannot force my action
  747. routine to the top of the action list for the activity desired, so the window
  748. manager kills my window anyway BEFORE I can do anything about it.  And, to
  749. make matters worse, the window manager (Motif in this case) tacks its atoms
  750. and handlers onto the window at some unknown point down the line after the
  751. creation of the shell widget as far as I can tell.  So....
  752.  
  753. I have a procedure as an action routine for ClientMessage.  Then, if I get a
  754. property change event on the window manager protocols, I then tack on
  755. WM_SAVE_YOURSELF.  If I get this request, I clean up (it seems to happen on
  756. WM_DELETE_WINDOW, BTW, if you remove WM_DELETE_WINDOW from the WM protocols
  757. atom) and exit.  Works great and is less filling overall:-)."
  758.  
  759.  
  760. -----------------------------------------------------------------------------
  761. Subject: 27)  Is there an mwm virtual desktop manager?
  762.  
  763. Answer: Peter E. Wagner (pew@cs.brown.edu): Imagine that your "desktop"
  764. extends beyond the view provided by your monitor.  A virtual window manager
  765. gives you access to the space beyond your viewport (i.e. your screen) by
  766. allowing you to move the viewport to other areas of the extended desktop.
  767.  
  768. The first one is Solbourne's swm, which spawned vtwm/tvtwm/olvwm.
  769.  
  770. David B. Lewis created one.  suresh@unipalm.co.uk has further developed it
  771. into the UniPalm product DOORS, which is only available as a source code
  772. extension to the MOTIF window manager.  The price of the source and unlimited
  773. right to distribute binaries is 10,000 pounds Sterling.  Alternately, source
  774. and right to use within one company is 2,000 pounds Sterling.  Contact Peter
  775. Dawe
  776.  
  777. Unipalm Limited                         Voice: +44 (0) 223 420002
  778. 216 The Science Park                    Fax:   +44 (0) 223 426868
  779. CAMBRIDGE
  780. CB4 4WA
  781.  
  782.  
  783.  
  784. An enhancement request for such an object has been filed with OSF.
  785.  
  786. -----------------------------------------------------------------------------
  787. END OF PART ONE
  788.  
  789. -----------------------------------------------------------------------------
  790. Subject: 28) TOPIC: MOTIF GENERATORS
  791.  
  792. -----------------------------------------------------------------------------
  793. Subject: 29)*  What prototyping tools are there to generate Motif code?
  794. [Last modified: November 92]
  795.  
  796. Answer: [An FAQ is for "personal opinions" on these tools.  I don't think it
  797. is appropriate to give such opinions through this particular posting, so I
  798. haven't included any.]
  799.  
  800. `Prototyping tools' come in two forms: those that can be used to design the
  801. interface only (GUI builder), and those that go beyond this to give support
  802. for application code (User Interface Management Systems).  There are a number
  803. of commercial and non-commercial tools of both kinds that will support the
  804. Motif interface.  They include:
  805.  
  806. GUI builders:
  807.  
  808. Builder Xcessory
  809. X Build
  810. ExoCODE/xm
  811.  
  812.  
  813. UIMS:
  814.  
  815. WINTERP
  816. ALEX
  817. Widget Creation Library
  818. UIMX
  819. Serpent
  820. TeleUse
  821. X-Designer
  822. XFaceMaker2
  823. MOTIFATION
  824. MetaCard
  825.  
  826.  
  827. Some contact addresses are:
  828.  
  829. WINTERP: You may obtain the current source, documentation, and examples via
  830. anonymous ftp from host export.lcs.mit.edu: in directory contrib/winterp you
  831. will find the compress(1)'d tar(1) file winterp.tar.Z. If you do not have
  832. Internet access you may request the source code to be mailed to you by sending
  833. a message to winterp-source%hplnpm@hplabs.hp.com or hplabs!hplnpm!winterp-
  834. source.
  835.  
  836. Serpent: The S/W is free (anonymous ftp) from ftp.sei.cmu.edu.  For more info
  837. contact erik/robert at serpent-info@sei.cmu.edu.
  838.  
  839. TeleUse: In the U.K., send mail to xtech@unipalm.co.uk or call +44 954 211862.
  840. In the US contact Telesoft at:
  841.  
  842. TeleSoft, 5959 Cornerstone Court West, San Diego, CA 92121-9891
  843.              Phone: +1 619-457-2700
  844.                     +1 619-452-1334 Fax
  845.              Email: guisales@telesoft.com (Sales),
  846.                     guisupport@telesoft.com (Customer Support)
  847.  
  848.  
  849. Builder Xcessory from ICS.  More details are available by sending a request to
  850. info@ics.com.  Address: ICS Inc., 201 Broadway, Cambridge MA 02139, Tel. (617)
  851. 621-0060, Fax. (617) 621-9555
  852.  
  853. X-Designer: From Imperial Software Technology in the UK.  Email address is
  854. sales@ist.co.uk.  (+44) 743 587055
  855.  
  856. Recently, V.I. Corporation have become the distributor for the X-Designer
  857. product in the United States.  In addition, IST and V.I. Corporation have
  858. developed a product called DVX-Designer that merges X-Designer with their GUI
  859. product called DataViews.  Other merged products are in the works.  For more
  860. information, people can contact:
  861.  
  862.         V.I. Corporation
  863.         47 Pleasant Street
  864.         Northampton, MA  01060
  865.         Phone: (413) 586-4144
  866.         Fax: (413) 586-3805
  867.         Email: vi@vicorp.com
  868.  
  869.  
  870. ExoCODE/xm: From Expert Object Corp., 7250 Cicero Avenue, Lincolnwood, IL
  871. 60646 (708)676-5555.
  872.  
  873. X Build: From Nixdorf Computer (Waltham, MA) xbuild@nixdorf.com
  874.  
  875.  
  876. ExoCode: From EXOC (Chicago, IL)
  877.  
  878. UIMX: Visual Edge Software Limited, 3870 Cote Vertu, St Laurent, Quebec, H4R
  879. 1V4, Phone: (514) 332-6430, Fax:   (514) 332-5914, or: Visual Edge Software
  880. Ltd., 101 First Street, Suite 443, Los Altos, CA 94022, Phone: (415) 948-0753,
  881. Fax:   (415) 948-0843
  882.  
  883. The Widget Creation Library: The distribution is available in several ways.
  884. The preferred approach it for you to get the compressed tar file using
  885. anonymous ftp from:
  886.  
  887.     export.lcs.mit.edu    (18.30.0.238) /contrib/Wcl.1.06.tar.Z
  888.  
  889.  
  890. XFaceMaker2: NSL -  Non Standard Logics S.A., 57-59, rue Lhomond, 75005  Paris
  891. - France, Phone: +33 (1) 43.36.77.50, Fax:   +33 (1) 43.36.59.78 email:
  892. requests@nsl.fr or requests%nsl.fr@inria.fr for information.
  893.  
  894. Their North American office: Non Standard Logics, Inc., 4141 State Street,
  895. Suite B-11, Santa Barbara CA 93110, Tel: 805 964 9599, Fax: 805 964 4367
  896.  
  897.  
  898. MOTIFATION: AKA EDV, Universitaetsstrasse 125, 4630 Bochum, Germany, Tel: +49
  899. (0) 234 / 33397-0, Fax: +49 (0) 234 / 33397-40
  900.  
  901.  
  902. ALEX: For more information contact Michael Karliner on (+44) 81 566 2307 or
  903. E-mail to alex@s-strat.co.uk.  ALEX Technologies, Waterman's Yard, 32a The
  904. Mall, Ealing, London W5, UK.
  905.  
  906. MetaCard: MetaCard 1.0 is supported on five popular UNIX/X11 platforms: SPARC,
  907. Sun3, DECstation, HP-9000/300, and SCO ODT.  An HP-9000/700 port is underway
  908. and should be available by the end of July.  [They] plan to support IBM
  909. RS/6000, SGI Iris, and DG AViiON sometime fall '92.  For more information, or
  910. to receive a free save-disabled but licensable copy of MetaCard, email to
  911. info@metacard.com or call 303- 447-3936.  If you have anonymous FTP access to
  912. the Internet, you can download the current engines, documentation, and an
  913. unlicensed Home stack from ftp.metacard.com (128.138.213.21), directory
  914. MetaCard.  Commercial users can get MetaCard from world.std.com
  915. (192.74.137.5), directory pub/Metacard.  If you don't have an anonymous ftp
  916. access, you can also download MetaCard from The World using kermit or xmodem
  917. from the ~ftp/pub/MetaCard directory.  Sign up by calling 617-739-0202 (voice)
  918. or via modem by dialing 617-739-9753 (7 bits even parity) and logging in as
  919. new.
  920.  
  921. MetaCard 1.2 Beta 5 is now available for anonymous FTP from ftp.metacard.com
  922. (directory MetaCard/1.2B5), and ftp.uu.net (directory vendor/MetaCard/1.2B5).
  923.  
  924.  
  925. -----------------------------------------------------------------------------
  926. Subject: 30) TOPIC: TEXT WIDGET
  927.  
  928. -----------------------------------------------------------------------------
  929. Subject: 31) Why does  pressing  <return> in a text widget do nothing?  This
  930. happens using Motif 1.0 when I have a text widget inside a bulletin board (or
  931. form) inside a dialog shell. (In Motif 1.1 it is fixed for both text and list
  932. widgets.)
  933.  
  934. Answer: In single line mode, pressing the <return> key usually invokes the
  935. activate() action, and in multi-line mode, the newline() action.  However,
  936. whenever a widget is the child of a bulletin board widget which is the child
  937. of a dialog shell, the bulletin board forces all of its children to translate
  938. <return> to the bulletin board action Return() which is usually associated
  939. with the default button of the dialog.  To restore the text actions of
  940. activate() or newline(), you need to overide the Return() action of the
  941. bulletin board.
  942.  
  943.  
  944.         /* declarations */
  945.         /* for a single line widget */
  946.         char newTrans[] = "<Key>Return : activate()";
  947.         /* for a multi line widget */
  948.         char newTrans[] = "<Key>Return : newline()";
  949.         XtTranslations transTable;
  950.  
  951.         /* in executable section */
  952.  
  953.         transTable = XtParseTranslationTable(newTrans);
  954.  
  955.         /* after creating but before managing text widget */
  956.  
  957.         XtOverrideTranslations(textWidget, transTable);
  958.  
  959.  
  960. -----------------------------------------------------------------------------
  961. Subject: 32) When I add text to a scrolling text widget how can I get the new
  962. text to show?
  963.  
  964. Answer: Use the call undocumented in Motif 1.0
  965.  
  966.         void XmTextShowPosition(w, position)
  967.         Widget w;
  968.         XmTextPosition position;
  969.  
  970. where the position is the number of characters from the beginning of the
  971. buffer of the text to be displayed. If you don't know how many characters are
  972. in the buffer, use another call undocumented in Motif 1.0
  973.  
  974.         position = XmTextGetLastPosition(w)
  975.  
  976.  
  977. -----------------------------------------------------------------------------
  978. Subject: 33)* Does the text widget support 16 bit character fonts?
  979.  
  980.  
  981. [Last modified: November 92]
  982.  
  983. Answer: R5 has support for 16 bit character sets, and Motif 1.2 uses that.
  984. Neither Motif 1.0 nor 1.1 support 16 bit sets.
  985.  
  986. -----------------------------------------------------------------------------
  987. Subject: 34) How can I stop the text widget from echoing characters typed?  I
  988. need to turn off echo for password input.
  989.  
  990. Answer: Use the modifyVerifyCallback to tell when input is received. Set the
  991. `doit' field in the XmTextVerifyCallbackStruct to False to stop the echo. In
  992. Motif 1.0 this will cause a beep per character: Live with it, because at 1.1
  993. you can turn it off.  Note that password hiding is inherently insecure in X -
  994. someone may have an X grab on the keyboard and be reading all characters typed
  995. in anyway.
  996.  
  997. Another solution often proposed is to set the foreground and background
  998. colours to be the same, effectively hiding the text.  This has a major flaw:
  999. someone may select the text (triple click the mouse to get the line), and then
  1000. paste the password into say an xterm with *different* foreground and
  1001. background colours.  This immediately shows the password.
  1002.  
  1003. -----------------------------------------------------------------------------
  1004. Subject: 35) How can I replace characters typed with say a `*'?  I want to
  1005. replace input for password entry.
  1006.  
  1007. Answer: In Motif 1.1 Use the modifyVerifyCallback to tell when input is
  1008. received.  Set text->ptr in the callback structure to '*'. This does not work
  1009. under 1.0 because of an oversight in which changes to this are ignored.  In
  1010. Motif 1.0, what you can do is set the doit flag to 'false' so the text is not
  1011. displayed. Then set a static boolean to True to prevent re-entrance.  Next
  1012. call XmTextReplace() to display your '*'.  then reset your re-entrance flag to
  1013. False.  XmTextReplace() will call the XmNmodifyVerify callback.  To prevent
  1014. getting into an infinite loop, you need the re-entrance flag.
  1015.  
  1016. The following program from Dan Heller illustrates this:
  1017. --------------
  1018. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1019.  * This program is freely distributable without licensing fees and
  1020.  * is provided without guarantee or warranty expressed or implied.
  1021.  * This program is -not- in the public domain.  This program appears
  1022.  * in the Motif Programming Manual, O'Reilly Volume 6.
  1023.  */
  1024.  
  1025. /* passwd.c -- prompt for a passwd.  Meaning, all input looks like
  1026.  * a series of *'s.  Store the actual data typed by the user in
  1027.  * an internal variable.  Don't allow paste operations.  Handle
  1028.  * backspacing by deleting all text from insertion point to the
  1029.  * end of text.
  1030.  */
  1031. #include <Xm/Text.h>
  1032. #include <Xm/LabelG.h>
  1033. #include <Xm/RowColumn.h>
  1034. #include <ctype.h>
  1035.  
  1036. void check_passwd();
  1037. char *passwd; /* store user-typed passwd here. */
  1038.  
  1039. main(argc, argv)
  1040. int argc;
  1041. char *argv[];
  1042. {
  1043.     Widget        toplevel, text_w, rowcol;
  1044.     XtAppContext  app;
  1045.  
  1046.     toplevel = XtVaAppInitialize(&app, "Demos",
  1047.         NULL, 0, &argc, argv, NULL, NULL);
  1048.  
  1049.     rowcol = XtVaCreateWidget("rowcol",
  1050.         xmRowColumnWidgetClass, toplevel,
  1051.         XmNorientation, XmHORIZONTAL,
  1052.         NULL);
  1053.  
  1054.     XtVaCreateManagedWidget("Password:",
  1055.         xmLabelGadgetClass, rowcol, NULL);
  1056.     text_w = XtVaCreateManagedWidget("text_w",
  1057.         xmTextWidgetClass, rowcol, NULL);
  1058.  
  1059.     XtAddCallback(text_w, XmNmodifyVerifyCallback, check_passwd, NULL);
  1060.     XtAddCallback(text_w, XmNactivateCallback, check_passwd, NULL);
  1061.  
  1062.     XtManageChild(rowcol);
  1063.     XtRealizeWidget(toplevel);
  1064.     XtAppMainLoop(app);
  1065. }
  1066.  
  1067. void
  1068. check_passwd(text_w, unused, cbs)
  1069. Widget        text_w;
  1070. XtPointer     unused;
  1071. XmTextVerifyCallbackStruct *cbs;
  1072. {
  1073.     char *new;
  1074.     int len;
  1075.  
  1076.     if (cbs->reason == XmCR_ACTIVATE) {
  1077.         printf("Password: %s\n", passwd);
  1078.         return;
  1079.     }
  1080.  
  1081.     if (cbs->text->ptr == NULL) { /* backspace */
  1082.         cbs->endPos = strlen(passwd); /* delete from here to end */
  1083.         passwd[cbs->startPos] = 0; /* backspace--terminate */
  1084.         return;
  1085.     }
  1086.  
  1087.     if (cbs->text->length > 1) {
  1088.         cbs->doit = False; /* don't allow "paste" operations */
  1089.         return; /* make the user *type* the password! */
  1090.     }
  1091.  
  1092.     new = XtMalloc(cbs->endPos + 2); /* new char + NULL terminator */
  1093.     if (passwd) {
  1094.         strcpy(new, passwd);
  1095.         XtFree(passwd);
  1096.     } else
  1097.         new[0] = NULL;
  1098.     passwd = new;
  1099.     strncat(passwd, cbs->text->ptr, cbs->text->length);
  1100.     passwd[cbs->endPos + cbs->text->length] = 0;
  1101.  
  1102.     for (len = 0; len < cbs->text->length; len++)
  1103.         cbs->text->ptr[len] = '*';
  1104. }
  1105.  
  1106.  
  1107. -----------------------------------------------------------------------------
  1108. Subject: 36) How can I best add a large piece of text to a scrolled text
  1109. widget?  In some versions of Motif 1.0 even using XmTextSetString, it insists
  1110. on adding the text one line at a time, adjusting the scroll bar each time. It
  1111. looks awful and is slow.
  1112.  
  1113. Answer: If you don't have this problem, use XmTextSetString to set all of the
  1114. text in the widget.  If you do have this slowdown problem even using
  1115. XmTextSetString, unmanage the widget, add the text and then manage it again.
  1116. This may cause the window to blink, but you have to put up with that or switch
  1117. to a different version of Motif.
  1118.  
  1119. -----------------------------------------------------------------------------
  1120. Subject: 37) How can I highlight text in the Text widget?
  1121.  
  1122. Answer: From: argv@zipcode.com (Dan Heller)
  1123.  
  1124. If you don't need font or color changes, you can do all this using a Text
  1125. widget very easily [in Motif 1.1, anyway].
  1126.  
  1127.         loop() {
  1128.             pos = offset_of_pattern_in_text_widget(pattern, text_w);
  1129.             search_len = strlen(pattern);
  1130.             XmTextSetHighlight(text_w, pos, pos+search_len,
  1131.                         XmHIGHLIGHT_SELECTED);
  1132.         }
  1133.  
  1134.  
  1135. There are two choices for highlighting: reverse video (HIGHLIGHT_SELECTED) and
  1136. underlined (HIGHLIGHT_SECONDARY_SELECTED).  Be careful that your users won't
  1137. confuse your highlights with actual selections!
  1138.  
  1139. -----------------------------------------------------------------------------
  1140. Subject: 38)  How can I select all of the text in a widget programmatically?
  1141. So that some initial text is displayed, but anything typed replaces it.
  1142.  
  1143. Answer: XmTextSetSelection(Text1, 0, XmTextGetLastPosition(Text1), event-
  1144. >xbutton.time);
  1145.  
  1146. where Text1 is the widget in question (obviously) and event is some event that
  1147. triggered this call.  You can use XtLastTimestampProcessed( display) instead
  1148. of xbutton.time if you don't happen to have an event pointer handy.
  1149.  
  1150.  
  1151.  
  1152.  
  1153. -----------------------------------------------------------------------------
  1154. Subject: 39) How can I change colours of text in the Text widget?  I want some
  1155. of the text in one colour, some in another.
  1156.  
  1157. Answer: You can't.  Text stores an ordinary string, and points where
  1158. `highlights' of various types begin and end.  These highlights are all the
  1159. control you have over components of the text.  See the previous question.
  1160.  
  1161.  
  1162. -----------------------------------------------------------------------------
  1163. Subject: 40) How can I change the font of text in the Text widget?  I want
  1164. some of the text in one font, some in another.
  1165.  
  1166. Answer: You can't in Text (see the previous question).  If you wanted readonly
  1167. text, you could do it by using a label instead.  Label uses XmStrings, which
  1168. can contain multiple character sets in the one string.
  1169.  
  1170. -----------------------------------------------------------------------------
  1171. Subject: 41) Is there an emacs binding for the text widget?
  1172.  
  1173. Answer: This set is due to Kee Hinckley (nazgul@alfalfa.com):
  1174.  
  1175. *XmText.translations: #override\n\
  1176.         Ctrl <Key>b:            backward-character()\n\
  1177.         Alt <Key>b:             backward-word()\n\
  1178.         Meta <Key>b:            backward-word()\n\
  1179.         Shift Alt <Key>b:       backward-word(extend)\n\
  1180.         Shift Meta <Key>b:      backward-word(extend)\n\
  1181.         Alt <Key>[:             backward-paragraph()\n\
  1182.         Meta <Key>[:            backward-paragraph()\n\
  1183.         Shift Alt <Key>[:       backward-paragraph(extend)\n\
  1184.         Shift Meta <Key>[:      backward-paragraph(extend)\n\
  1185.         Alt <Key><:             beginning-of-file()\n\
  1186.         Meta <Key><:            beginning-of-file()\n\
  1187.         Ctrl <Key>a:            beginning-of-line()\n\
  1188.         Shift Ctrl <Key>a:      beginning-of-line(extend)\n\
  1189.         Ctrl <Key>osfInsert:    copy-clipboard()\n\
  1190.         Shift <Key>osfDelete:   cut-clipboard()\n\
  1191.         Shift <Key>osfInsert:   paste-clipboard()\n\
  1192.         Alt <Key>>:             end-of-file()\n\
  1193.         Meta <Key>>:            end-of-file()\n\
  1194.         Ctrl <Key>e:            end-of-line()\n\
  1195.         Shift Ctrl <Key>e:      end-of-line(extend)\n\
  1196.         Ctrl <Key>f:            forward-character()\n\
  1197.         Alt <Key>]:             forward-paragraph()\n\
  1198.         Meta <Key>]:            forward-paragraph()\n\
  1199.         Shift Alt <Key>]:       forward-paragraph(extend)\n\
  1200.         Shift Meta <Key>]:      forward-paragraph(extend)\n\
  1201.         Ctrl Alt <Key>f:        forward-word()\n\
  1202.         Ctrl Meta <Key>f:       forward-word()\n\
  1203.         Ctrl <Key>d:            kill-next-character()\n\
  1204.         Alt <Key>BackSpace:     kill-previous-word()\n\
  1205.         Meta <Key>BackSpace:    kill-previous-word()\n\
  1206.         Ctrl <Key>w:            key-select() kill-selection()\n\
  1207.         Ctrl <Key>y:            unkill()\n\
  1208.         Ctrl <Key>k:            kill-to-end-of-line()\n\
  1209.         Alt <Key>Delete:        kill-to-start-of-line()\n\
  1210.         Meta <Key>Delete:       kill-to-start-of-line()\n\
  1211.         Ctrl <Key>o:            newline-and-backup()\n\
  1212.         Ctrl <Key>j:            newline-and-indent()\n\
  1213.         Ctrl <Key>n:            next-line()\n\
  1214.         Ctrl <Key>osfLeft:      page-left()\n\
  1215.         Ctrl <Key>osfRight:     page-right()\n\
  1216.         Ctrl <Key>p:            previous-line()\n\
  1217.         Ctrl <Key>g:            process-cancel()\n\
  1218.         Ctrl <Key>l:            redraw-display()\n\
  1219.         Ctrl <Key>osfDown:      next-page()\n\
  1220.         Ctrl <Key>osfUp:        previous-page()\n\
  1221.         Ctrl <Key>space:        set-anchor()\n
  1222.  
  1223.  
  1224. ! If you'd like the Delete key to work like backspace instead of deleting
  1225. ! backwards, add the following definition to the lines above.
  1226. !       <Key>osfDelete: delete-previous-character()\n\
  1227.  
  1228. ! These aren't included because they could intefere with
  1229. | menu accelerators (or vice versa)
  1230. !       Alt <Key>p:             backward-paragraph()\n\
  1231. !       Meta <Key>p:            backward-paragraph()\n\
  1232. !       Shift Alt<Key>p:        backward-paragraph(extend)\n\
  1233. !       Shift Meta<Key>p:       backward-paragraph(extend)\n\
  1234. !       Alt <Key>w:             copy-clipboard()\n\
  1235. !       Meta <Key>w:            copy-clipboard()\n\
  1236. !       Ctrl Alt <Key>w:        cut-clipboard()\n\
  1237. !       Ctrl Meta <Key>w:       cut-clipboard()\n\
  1238. !       Alt <Key>y:             paste-clipboard()\n\
  1239. !       Meta <Key>y:            paste-clipboard()\n\
  1240. !       Alt <Key>f:             forward-word()\n\
  1241. !       Meta <Key>f:            forward-word()\n\
  1242. !       Alt <Key>n:             forward-paragraph()\n\
  1243. !       Meta <Key>n:            forward-paragraph()\n\
  1244. !       Shift Alt <Key>n:       forward-paragraph(extend)\n\
  1245. !       Shift Meta <Key>n:      forward-paragraph(extend)\n\
  1246. !       Shift Alt <Key>f:       forward-word(extend)\n\
  1247. !       Shift Meta <Key>f:      forward-word(extend)\n\
  1248. !       Alt <Key>d:             kill-next-word()\n\
  1249. !       Meta <Key>d:            kill-next-word()\n\
  1250. !       Alt <Key>h:             select-all()\n\
  1251. !       Meta <Key>h:            select-all()\n\
  1252.  
  1253. Similar sets of translations have been suggested by others.
  1254.  
  1255. -----------------------------------------------------------------------------
  1256. Subject: 42) How can I use a file as the text source for a Text widget?
  1257.  
  1258. Answer: You can't do it directly like you can with the Athena Text widget.
  1259. Instead, read the text from the file into a string (all of it!) and then use
  1260. XmTextSetString.  Alternatively, read blocks of characters and add them at the
  1261. end of the text using XmTextInsertString.  The following is an excerpt from
  1262. Dan Heller's "file_browser.c":
  1263.  
  1264.     /* file_browser.c -- use a ScrolledText object to view the
  1265.      * contents of arbitrary files chosen by the user from a
  1266.      * FileSelectionDialog or from a single-line text widget.
  1267.      */
  1268.  
  1269.     ...
  1270.     struct stat statb;
  1271.  
  1272.     /* make sure the file is a regular text file and open it */
  1273.     if (stat(filename, &statb) == -1 ||
  1274.             (statb.st_mode & S_IFMT) != S_IFREG ||
  1275.             !(fp = fopen(filename, "r"))) {
  1276.         if ((statb.st_mode & S_IFMT) == S_IFREG)
  1277.             perror(filename); /* send to stderr why we can't read it */
  1278.         else
  1279.             fprintf(stderr, "%s: not a regular file0, filename);
  1280.         XtFree(filename);
  1281.         return;
  1282.     }
  1283.  
  1284.     /* put the contents of the file in the Text widget by allocating
  1285.      * enough space for the entire file, reading the file into the
  1286.      * allocated space, and using XmTextFieldSetString() to show the file.
  1287.      */
  1288.     if (!(text = XtMalloc((unsigned)(statb.st_size+1)))) {
  1289.         fprintf(stderr, "Can't alloc enough space for %s", filename);
  1290.         XtFree(filename);
  1291.         fclose(fp);
  1292.         return;
  1293.     }
  1294.  
  1295.     if (!fread(text, sizeof(char), statb.st_size+1, fp))
  1296.         fprintf(stderr, "Warning: may not have read entire file!0);
  1297.  
  1298.     text[statb.st_size] = 0; /* be sure to NULL-terminate */
  1299.  
  1300.     /* insert file contents in Text widget */
  1301.     XmTextSetString(text_w, text);
  1302.  
  1303.  
  1304.  
  1305.  
  1306. -----------------------------------------------------------------------------
  1307. Subject: 43) How can put Text in overstrike mode instead of insert?
  1308.  
  1309. Answer: There is no direct way. This was posted by Edmond Pitt
  1310. (ejp@bohra.cpg.oz) The correct answer to the question is to put the following
  1311. in a modifyVerify callback, where 'mvcb' is the XmTextVerifyCallbackStruct,
  1312. and 'overstriking' is defined by you:
  1313.  
  1314.     if (overstriking && mvcb->text->length == 1)
  1315.     {
  1316.         _XmTextDisableRedisplay(w,FALSE);
  1317.         XtCallActionProc(w,"delete-next-character",mvcb->event,0);
  1318.         _XmTextEnableRedisplay(w);
  1319.     }
  1320.  
  1321. _XmText{Dis,En}ableRedisplay() are XmText{Dis,En}ableRedisplay() in 1.0, but
  1322. X11R3 has no XtCallActionProc() anyway. For this environment you need my 1.0.3
  1323. Text widget patches posted last year & available on request.
  1324.  
  1325.  
  1326. -----------------------------------------------------------------------------
  1327. Subject: 44) How can I make the Delete key do a backspace?
  1328.  
  1329. Answer: Put this in your .Xdefaults
  1330.  
  1331.     *XmText.translations: #override <Key>osfDelete: delete-previous-character()
  1332.  
  1333.  
  1334. -----------------------------------------------------------------------------
  1335. Subject: 45) TOPIC: LIST WIDGET
  1336.  
  1337. -----------------------------------------------------------------------------
  1338. Subject: 46) How do I best put a new set of items into a list?
  1339.  
  1340. Answer: Set the new list count and list by XtSetArgs and install them by
  1341. XtSetValues.
  1342.  
  1343.     XmString list[SIZE];
  1344.     int list_size;
  1345.  
  1346.     XtSetArg (args[n], XmNitemCount, list_size); n++;
  1347.     XtSetArg (args[n], XmNitems, list); n++;
  1348.     XtSetValues (w, args, n);
  1349.  
  1350. Each time the list is reset by this the old contents are freed by the widget
  1351. and the new supplied list is copied.  Do *not* free the old list of items
  1352. yourself as this would result in the space being freed twice.  It is not
  1353. necessary to remove the items one at a time, nor to "zero" out the list first.
  1354.  
  1355. -----------------------------------------------------------------------------
  1356. Subject: 47)  Can I have strings with different fonts in a list?
  1357.  
  1358. Answer: Yes. The strings are XmStrings. Each one can be created using a
  1359. different character set using a different font.
  1360.  
  1361.  
  1362. -----------------------------------------------------------------------------
  1363. Subject: 48) Can I get a bitmap to show in a list item like I can in a Label?
  1364. I want to place a bitmap along with some normal text in my list items.
  1365.  
  1366. Answer: No. The list contains XmStrings, and these only allow text in various
  1367. character sets. The workaround is to define your font containing the icons you
  1368. want. Then you can create a fontlist containing your icon font and the font
  1369. you want the text in, and then make your items multi-segment XmStrings where
  1370. the first segment contains the code of the icon you want with a charset that
  1371. matches the icon font in your fontlist and the second segment with a charset
  1372. matching the text font.
  1373.  
  1374.  
  1375. -----------------------------------------------------------------------------
  1376. Subject: 49) Can I have items with different colours in a list?
  1377.  
  1378. Answer: No.  The list contains XmStrings, and these only allow text in various
  1379. character sets. Since the items are XmStrings, you can already change the font
  1380. of an item by replacing it with an item with the same text and a different
  1381. charset tag.  Adding support for color would require modification of the
  1382. internal data structure in XmList as well as modification to the drawing
  1383. routines.  A possible workaround is to use a rowcolumn of buttons which can be
  1384. individually set.  However, you would have to do all list functionality
  1385. yourself.
  1386.  
  1387.  
  1388. -----------------------------------------------------------------------------
  1389. Subject: 50) Can I grey out an item in a list?  I want to make insensitive
  1390. items in a list so that they cannot be selected.
  1391.  
  1392. Answer:
  1393.  
  1394. From W. Scott Meeks of OSF:
  1395.  
  1396. Unfortunately, you can't do it directly since the list items aren't individual
  1397. widgets.  We've had other requests for this technology, but it didn't make the
  1398. cut for 1.2; it should be in some future release.
  1399.  
  1400. However, you can probably fake it in your application with some difficulty.
  1401. First, a list item is an XmString, so you can specify a different charset for
  1402. the item than for other items in the list and then specify a font in the
  1403. list's fontlist that matches the charset and gives you the visual you want.
  1404. The next problem is making the item unselectable.  One idea would be to have
  1405. the application keep track of the insensitive items and the items currently
  1406. selected.  Then you would set up a selection callback that when called would
  1407. check the item selected against the list of insensitive items and if the
  1408. selected item matched would deselect that item and reselect the previously
  1409. selected items.  Otherwise it would just update the application's list of
  1410. selected items.  The major drawback with this approach is that you'll get
  1411. flashing whenever the list selects an item and your application immediately
  1412. de-selects.  Unfortunately I can't think of a way around this without mucking
  1413. with the list internals.
  1414.  
  1415. Another alternative suggested is to use instead a column of say read only text
  1416. widgets which you can make insensitive.
  1417.  
  1418. -----------------------------------------------------------------------------
  1419. Subject: 51)  Can I have multi-line items in a list?
  1420. [Last modified: August 92]
  1421.  
  1422. Answer: Motif 1.0 and 1.1 both have problems with multi-line items in a list.
  1423. They should work okay in Motif 1.2.
  1424.  
  1425. -----------------------------------------------------------------------------
  1426. Subject: 52)+How can I tell the position of selected items in a list?
  1427.  
  1428. [Last modified: Oct 92]
  1429.  
  1430. Answer: From  W. Scott Meeks:
  1431.  
  1432. 1) All XmList selection callbacks get an XmListCallbackStruct which includes
  1433. the item selected and its position.  In addition, the multiple and extended
  1434. selection callbacks also get a list of the selected items.  This approach
  1435. requires that your application saves this information if you need it outside
  1436. of the immediate callback.
  1437.  
  1438. 2) At any time you can XtGetValues the XmNselectedItems and
  1439. XmNselectedItemCount resources.  The problem with this approach is that
  1440. identical items may or may not show up in multiple times in this list and the
  1441. position in the selectedItems list may not relate directly to the position in
  1442. the items list.
  1443.  
  1444. 3) You can call XmListGetSelectedPos on the list widget.  This will return a
  1445. list of the positions of all selected items.
  1446.  
  1447. -----------------------------------------------------------------------------
  1448. Subject: 53) TOPIC: FILE SELECTION BOX WIDGET
  1449.  
  1450. -----------------------------------------------------------------------------
  1451. Subject: 54) What is libPW.a and do I need it?  My manual says I need to link
  1452. in libPW.a to use the File Selection Box.  I can't find it on my system.
  1453.  
  1454. Answer: The libPW.a is the Programmers Workbench library which is an ATT
  1455. product not included in Berkeley based systems, hence it is not found in SunOS
  1456. or Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which chose ATT in
  1457. this case).  It contains the regex(3) routines (regcmp, regex).  Some systems
  1458. which don't have these in the libc.a need to link with -lPW.  Some systems
  1459. which have the regex(3) routines in there also have the libPW.a.  If you have
  1460. regex(3) in libc, and it works, don't link with libPW.  If you don't have
  1461. regex(3) in libc, and you don't have a libPW, then check some sites on the net
  1462. for public domain replacements (several exist), or call your vendor.
  1463.  
  1464. In most versions of Motif (see the doco), you can compile FileSB.c with
  1465. -DNO_REGEX if you don't have it.
  1466.  
  1467. -----------------------------------------------------------------------------
  1468. Subject: 55) What are these compile errors: Undefined symbol _regcmp?
  1469.  
  1470. Answer: You need to link in the libPW library - see previous question.
  1471.  
  1472.  
  1473. -----------------------------------------------------------------------------
  1474. Subject: 56) What's wrong with the Motif 1.0 File Selection Box?  I can't set
  1475. the directory, change the directory or get the file mask to work.
  1476.  
  1477. Answer: The 1.0 File Selection Box is broken, and these don't work.  They
  1478. weren't fixed until Motif 1.04.  Use these later versions of 1.0 or switch to
  1479. Motif 1.1 where it changed a lot.
  1480.  
  1481. Joe Hildebrand has a work-around for some of this: Before popping up an
  1482. XmFileSelectionDialog, change to the directory you want.  When a file is
  1483. selected, check if it is a directory, so that we can change to it.  i.e.
  1484.  
  1485. static void show_file_box_CB(w, client_data, call_data)
  1486.    Widget               w;
  1487.    Widget               client_data;
  1488.    XmAnyCallbackStruct  *call_data;
  1489. {
  1490.    chdir("/users/hildjj/files");
  1491.    XtManageChild(client_data);
  1492. }
  1493.  
  1494. static void val_save(w, client_data, call_data)
  1495.    Widget       w;
  1496.    Widget       client_data;
  1497.    XmSelectionBoxCallbackStruct *call_data;
  1498. {
  1499.    struct stat buf;  /* struct stat is defined in stat.h */
  1500.    char *filename;
  1501.  
  1502.    /* get the file name from the FileSelectionBox */
  1503.    filename = SmX(call_data->value);
  1504.  
  1505.    /* get the status of the file named filename, and put it into buf */
  1506.    if (!stat(filename, &buf))
  1507.    {
  1508.       /* if it's a directory */
  1509.       /* if it's a directory */
  1510.       if(S_ISDIR(buf.st_mode))
  1511.       {
  1512.          /* change to that directory, and update the FileSelectionBox */
  1513.         chdir(filename);
  1514.         XmFileSelectionDoSearch(w, NULL);
  1515.       }
  1516.       else
  1517.          /* if it's a regular file */
  1518.          if(S_ISREG(buf.st_mode))
  1519.             /* ask if it should be overwritten */
  1520.             XtManageChild(valbox);
  1521.          else
  1522.             /* it's another kind of file.  What type, i can't think of,
  1523.                but it might happen */
  1524.             pop_up_error_box(client_data, "Error saving file");
  1525.    }
  1526.    else  /* we couldn't get the file status */
  1527.    {
  1528.       /* if it's because the file doesn't exist, we're golden */
  1529.       if (errno == ENOENT)
  1530.          save_file();
  1531.       else   /* there is some other problem getting the status.
  1532.                 e.g. bad path */
  1533.          pop_up_error_box(client_data, "Error saving file");
  1534.    }
  1535. }
  1536.  
  1537. this still doesn't implement the file masking stuff.
  1538.  
  1539.  
  1540. -----------------------------------------------------------------------------
  1541. END OF PART TWO
  1542.  
  1543. -----------------------------------------------------------------------------
  1544. Subject: 57) TOPIC: FORM WIDGET
  1545.  
  1546.  
  1547. -----------------------------------------------------------------------------
  1548. Subject: 58) Why don't labels in a Form resize when the label is changed?
  1549. I've got some labels in a form. The labels don't resize whenever the label
  1550. string resource is changed. As a result, the operator has to resize the window
  1551. to see the new label contents. I am using Motif 1.1.
  1552.  
  1553. Answer: This problem may happen to any widget inside a Form widget. The
  1554. problem was that the Form will resize itself when it gets geometry requests
  1555. from its children. If its preferred size is not allowed, the Form will
  1556. disallow all geometry requests from its children. The workaround is that you
  1557. should set any ancestor of the Form to be resizable. For the shell which
  1558. contains the Form you should set the shell resource XmNallowShellResize to be
  1559. True (by default, it is set to FALSE).  There is currently an inconsistency on
  1560. how resizing is being done, and it may get fixed in Motif 1.2.
  1561.  
  1562. From db@sunbim.be (Danny Backx)
  1563.  
  1564. Basically what you have to do is set the XmNresizePolicy on the Form to
  1565. XmRESIZE_NONE.  The facts seem to be that XmRESIZE_NONE does NOT mean "do not
  1566. allow resizes".  You may also have to set XmNresizable on the form to True.
  1567.  
  1568. -----------------------------------------------------------------------------
  1569. Subject: 59) How can I center a widget in a form?
  1570.  
  1571. Answer: One of Motif's trickier questions.  The problems are that: Form gives
  1572. no support for centering, only for edge attachments, and the widget must stay
  1573. in the center if the form or the widget is resized.  Just looking at
  1574. horizontal centering (vertical is similar) some solutions are:
  1575.  
  1576.  a.  Use the table widget instead of Form.
  1577.  
  1578.  b.  A hack free solution is from Dan Heller:
  1579.  
  1580.      /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1581.       * This program is freely distributable without licensing fees and
  1582.       * is provided without guarantee or warranty expressed or implied.
  1583.       * This program is -not- in the public domain.  This program is
  1584.       * taken from the Motif Programming Manual, O'Reilly Volume 6.
  1585.       */
  1586.  
  1587.      /* corners.c -- demonstrate widget layout management for a
  1588.       * BulletinBoard widget.  There are four widgets each labeled
  1589.       * top-left, top-right, bottom-left and bottom-right.  Their
  1590.       * positions in the bulletin board correspond to their names.
  1591.       * Only when the widget is resized does the geometry management
  1592.       * kick in and position the children in their correct locations.
  1593.       */
  1594.      #include <Xm/BulletinB.h>
  1595.      #include <Xm/PushBG.h>
  1596.  
  1597.      char *corners[] = {
  1598.          "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right",
  1599.      };
  1600.  
  1601.      static void resize();
  1602.  
  1603.      main(argc, argv)
  1604.      int argc;
  1605.      char *argv[];
  1606.      {
  1607.          Widget toplevel, bboard;
  1608.          XtAppContext app;
  1609.          XtActionsRec rec;
  1610.          int i;
  1611.  
  1612.          /* Initialize toolkit and create toplevel shell */
  1613.          toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
  1614.              &argc, argv, NULL, NULL);
  1615.  
  1616.          /* Create your standard BulletinBoard widget */
  1617.          bboard = XtVaCreateManagedWidget("bboard",
  1618.              xmBulletinBoardWidgetClass, toplevel, NULL);
  1619.  
  1620.          /* Set up a translation table that captures "Resize" events
  1621.           * (also called ConfigureNotify or Configure events).  If the
  1622.           * event is generated, call the function resize().
  1623.           */
  1624.          rec.string = "resize";
  1625.          rec.proc = resize;
  1626.          XtAppAddActions(app, &rec, 1);
  1627.          XtOverrideTranslations(bboard,
  1628.              XtParseTranslationTable("<Configure>: resize()"));
  1629.  
  1630.          /* Create children of the dialog -- a PushButton in each corner. */
  1631.          for (i = 0; i < XtNumber(corners); i++)
  1632.              XtVaCreateManagedWidget(corners[i],
  1633.                  xmPushButtonGadgetClass, bboard, NULL);
  1634.  
  1635.          XtRealizeWidget(toplevel);
  1636.          XtAppMainLoop(app);
  1637.      }
  1638.  
  1639.      /* resize(), the routine that is automatically called by Xt upon the
  1640.       * delivery of a Configure event.  This happens whenever the widget
  1641.       * gets resized.
  1642.       */
  1643.      static void
  1644.      resize(w, event, args, num_args)
  1645.      CompositeWidget w;   /* The widget (BulletinBoard) that got resized */
  1646.      XConfigureEvent *event;  /* The event struct associated with the event */
  1647.      String args[]; /* unused */
  1648.      int *num_args; /* unused */
  1649.      {
  1650.          WidgetList children;
  1651.          int width = event->width;
  1652.          int height = event->height;
  1653.          Dimension w_width, w_height;
  1654.          short margin_w, margin_h;
  1655.  
  1656.          /* get handle to BulletinBoard's children and marginal spacing */
  1657.          XtVaGetValues(w,
  1658.              XmNchildren, &children,
  1659.              XmNmarginWidth, &margin_w,
  1660.              XmNmarginHeight, &margin_h,
  1661.              NULL);
  1662.  
  1663.          /* place the top left widget */
  1664.          XtVaSetValues(children[0],
  1665.              XmNx, margin_w,
  1666.  
  1667.              XmNy, margin_h,
  1668.              NULL);
  1669.  
  1670.          /* top right */
  1671.          XtVaGetValues(children[1], XmNwidth, &w_width, NULL);
  1672.  
  1673.          /* To Center a widget in the middle of the BulletinBoard (or Form),
  1674.           * simply call:
  1675.           *   XtVaSetValues(widget,
  1676.                XmNx,    (width - w_width)/2,
  1677.                XmNy,    (height - w_height)/2,
  1678.                NULL);
  1679.           * and return.
  1680.           */
  1681.          XtVaSetValues(children[1],
  1682.              XmNx, width - margin_w - w_width,
  1683.              XmNy, margin_h,
  1684.              NULL);
  1685.          /* bottom left */
  1686.          XtVaGetValues(children[2], XmNheight, &w_height, NULL);
  1687.          XtVaSetValues(children[2],
  1688.  
  1689.              XmNx, margin_w,
  1690.              XmNy, height - margin_h - w_height,
  1691.              NULL);
  1692.          /* bottom right */
  1693.          XtVaGetValues(children[3],
  1694.              XmNheight, &w_height,
  1695.              XmNwidth, &w_width,
  1696.              NULL);
  1697.          XtVaSetValues(children[3],
  1698.              XmNx, width - margin_w - w_width,
  1699.              XmNy, height - margin_h - w_height,
  1700.              NULL);
  1701.      }
  1702.  
  1703.  c.  No uil solution has been suggested, because of the widget size problem
  1704.  
  1705. -----------------------------------------------------------------------------
  1706. Subject: 60) How do I line up two columns of widgets of different types?  I
  1707. have a column of say label widgets, and a column of text widgets and I want to
  1708. have them lined up horizontally. The problem is that they are of different
  1709. heights. Just putting them in a form or rowcolumn doesn't line them up
  1710. properly because the label and text widgets are of different height.
  1711.  
  1712. If you want the geometry to look like this
  1713.  
  1714.           -------------------------------------
  1715.          |          -------------------------- |
  1716.          |a label  |Some text                 ||
  1717.          |          -------------------------- |
  1718.                            ------------------- |
  1719.          |a longer label  |Some more text     ||
  1720.          |                 ------------------- |
  1721.          |                    ---------------- |
  1722.          |a very long label  |Even more text  ||
  1723.          |                    ---------------- |
  1724.           -------------------------------------
  1725.  
  1726. try
  1727.  
  1728. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1729.  * This program is freely distributable without licensing fees and
  1730.  * is provided without guarantee or warranty expressed or implied.
  1731.  * This program is -not- in the public domain.  This program is
  1732.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  1733.  */
  1734.  
  1735. /* text_form.c -- demonstrate how attachments work in Form widgets.
  1736.  * by creating a text-entry form type application.
  1737.  */
  1738.  
  1739. #include <Xm/PushB.h>
  1740. #include <Xm/PushBG.h>
  1741. #include <Xm/LabelG.h>
  1742. #include <Xm/Text.h>
  1743. #include <Xm/Form.h>
  1744.  
  1745. char *prompts[] = {
  1746.     "Name:", "Phone:", "Address:",
  1747.     "City:", "State:", "Zip:",
  1748. };
  1749.  
  1750. main(argc, argv)
  1751. int argc;
  1752. char *argv[];
  1753. {
  1754.     Widget toplevel, mainform, subform, label, text;
  1755.     XtAppContext app;
  1756.     char buf[32];
  1757.     int i;
  1758.  
  1759.     toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
  1760.         &argc, argv, NULL, NULL);
  1761.  
  1762.     mainform = XtVaCreateWidget("mainform",
  1763.         xmFormWidgetClass, toplevel,
  1764.         NULL);
  1765.  
  1766.     for (i = 0; i < XtNumber(prompts); i++) {
  1767.         subform = XtVaCreateWidget("subform",
  1768.             xmFormWidgetClass,   mainform,
  1769.             /* first one should be attached for form */
  1770.             XmNtopAttachment,    i? XmATTACH_WIDGET : XmATTACH_FORM,
  1771.             /* others are attached to the previous subform */
  1772.             XmNtopWidget,        subform,
  1773.             XmNleftAttachment,   XmATTACH_FORM,
  1774.             XmNrightAttachment,  XmATTACH_FORM,
  1775.             NULL);
  1776.         label = XtVaCreateManagedWidget(prompts[i],
  1777.             xmLabelGadgetClass,  subform,
  1778.             XmNtopAttachment,    XmATTACH_FORM,
  1779.             XmNbottomAttachment, XmATTACH_FORM,
  1780.             XmNleftAttachment,   XmATTACH_FORM,
  1781.             XmNalignment,        XmALIGNMENT_BEGINNING,
  1782.             NULL);
  1783.         sprintf(buf, "text_%d", i);
  1784.         text = XtVaCreateManagedWidget(buf,
  1785.             xmTextWidgetClass,   subform,
  1786.             XmNtopAttachment,    XmATTACH_FORM,
  1787.             XmNbottomAttachment, XmATTACH_FORM,
  1788.             XmNrightAttachment,  XmATTACH_FORM,
  1789.             XmNleftAttachment,   XmATTACH_WIDGET,
  1790.             XmNleftWidget,       label,
  1791.             NULL);
  1792.         XtManageChild(subform);
  1793.     }
  1794.     /* Now that all the forms are added, manage the main form */
  1795.     XtManageChild(mainform);
  1796.  
  1797.     XtRealizeWidget(toplevel);
  1798.     XtAppMainLoop(app);
  1799. }
  1800.  
  1801. If you resize horizontally it stretches the text widgets.  If you resize
  1802. vertically it leaves space under the bottom (if you don't resize, this is not
  1803. problem).
  1804.  
  1805. If you want the text widgets to be lined up on the left, as in
  1806.  
  1807.           ----------------------------------------
  1808.          |                    ------------------- |
  1809.          |          a label  |Some text          ||
  1810.          |                    ------------------- |
  1811.                               ------------------- |
  1812.          |   a longer label  |Some more text     ||
  1813.          |                    ------------------- |
  1814.          |                    ------------------- |
  1815.          |a very long label  |Even more text     ||
  1816.          |                    ------------------- |
  1817.           ----------------------------------------
  1818.  
  1819. try this
  1820.  
  1821. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  1822.  * This program is freely distributable without licensing fees and
  1823.  * is provided without guarantee or warranty expressed or implied.
  1824.  * This program is -not- in the public domain.  This program is
  1825.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  1826.  */
  1827.  
  1828. /* text_entry.c -- This demo shows how the RowColumn widget can be
  1829.  * configured to build a text entry form.  It displays a table of
  1830.  * right-justified Labels and Text widgets that extend to the right
  1831.  * edge of the Form.
  1832.  */
  1833. #include <Xm/LabelG.h>
  1834. #include <Xm/RowColumn.h>
  1835. #include <Xm/Text.h>
  1836.  
  1837. char *text_labels[] = {
  1838.     "Name:", "Phone:", "Address:", "City:", "State:", "Zip:",
  1839. };
  1840.  
  1841. main(argc, argv)
  1842. int argc;
  1843. char *argv[];
  1844. {
  1845.     Widget toplevel, rowcol;
  1846.     XtAppContext app;
  1847.     char buf[8];
  1848.     int i;
  1849.  
  1850.     toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
  1851.         &argc, argv, NULL, NULL);
  1852.  
  1853.     rowcol = XtVaCreateWidget("rowcolumn",
  1854.         xmRowColumnWidgetClass, toplevel,
  1855.         XmNpacking,        XmPACK_COLUMN,
  1856.         XmNnumColumns,     XtNumber(text_labels),
  1857.         XmNorientation,    XmHORIZONTAL,
  1858.         XmNisAligned,      True,
  1859.         XmNentryAlignment, XmALIGNMENT_END,
  1860.         NULL);
  1861.  
  1862.     /* simply loop thru the strings creating a widget for each one */
  1863.     for (i = 0; i < XtNumber(text_labels); i++) {
  1864.         XtVaCreateManagedWidget(text_labels[i],
  1865.             xmLabelGadgetClass, rowcol,
  1866.             NULL);
  1867.         sprintf(buf, "text_%d", i);
  1868.         XtVaCreateManagedWidget(buf,
  1869.             xmTextWidgetClass, rowcol,
  1870.             NULL);
  1871.     }
  1872.  
  1873.     XtManageChild(rowcol);
  1874.     XtRealizeWidget(toplevel);
  1875.     XtAppMainLoop(app);
  1876. }
  1877.  
  1878. This makes all objects exactly the same size.  It does not resize in nice
  1879. ways.
  1880.  
  1881. If you want the text widgets lined up on the left, and the labels to be the
  1882. size of the longest string, resizing nicely both horizontally and vertically,
  1883. as in
  1884.  
  1885.          -------------------------------------
  1886.         |                    ---------------- |
  1887.         |          a label  |Some text       ||
  1888.         |                    ---------------- |
  1889.                              ---------------- |
  1890.         |   a longer label  |Some more text  ||
  1891.         |                    ---------------- |
  1892.         |                    ---------------- |
  1893.         |a very long label  |Even more text  ||
  1894.         |                    ---------------- |
  1895.          -------------------------------------
  1896.  
  1897.  
  1898.  
  1899. Answer: Do this: to get the widgets lined up horizontally, use a form but
  1900. place the widgets using XmATTACH_POSITION.  In the example, attach the top of
  1901. the first label to the form, the bottomPosition to 33 (33% of the height).
  1902. Attach the topPosition of the second label to 33 and the bottomPosition to 66.
  1903. Attach the topPosition of the third label to 66 and the bottom of the label to
  1904. the form.  Do the same with the text widgets.
  1905.  
  1906. To get the label widgets lined up vertically, use the right attachment of
  1907. XmATTACH_OPPOSITE_WIDGET: starting from the one with the longest label, attach
  1908. widgets on the right to each other. In the example, attach the 2nd label to
  1909. the third, and the first to the second.  To get the text widgets lined up,
  1910. just attach them on the left to the labels.  To get the text in the labels
  1911. aligned correctly, use XmALIGNMENT_END for the XmNalignment resource.
  1912.  
  1913.         /* geometry for label 2
  1914.         */
  1915.         n = 0;
  1916.         XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1917.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1918.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1919.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
  1920.         XtSetArg (args[n], XmNtopPosition, 66); n++;
  1921.         XtSetValues (label[2], args, n);
  1922.  
  1923.         /* geometry for label 1
  1924.         */
  1925.         n = 0;
  1926.         XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1927.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
  1928.         XtSetArg (args[n], XmNbottomPosition, 66); n++;
  1929.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
  1930.         XtSetArg (args[n], XmNtopPosition, 33); n++;
  1931.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1932.         XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1933.         XtSetArg (args[n], XmNrightWidget, label[2]); n++;
  1934.         XtSetValues (label[1], args, n);
  1935.  
  1936.         /* geometry for label 0
  1937.         */
  1938.         n = 0;
  1939.         XtSetArg (args[n], XmNalignment, XmALIGNMENT_END); n++;
  1940.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
  1941.         XtSetArg (args[n], XmNbottomPosition, 33); n++;
  1942.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1943.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
  1944.         XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
  1945.         XtSetArg (args[n], XmNrightWidget, label[1]); n++;
  1946.         XtSetValues (label[0], args, n);
  1947.  
  1948.         /* geometry for text 0
  1949.         */
  1950.         n = 0;
  1951.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
  1952.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
  1953.         XtSetArg (args[n], XmNbottomPosition, 33); n++;
  1954.         XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1955.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1956.         XtSetArg (args[n], XmNleftWidget, label[0]); n++;
  1957.         XtSetValues (text[0], args, n);
  1958.  
  1959.         /* geometry for text 1
  1960.         */
  1961.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
  1962.         XtSetArg (args[n], XmNtopPosition, 33); n++;
  1963.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_POSITION); n++;
  1964.         XtSetArg (args[n], XmNbottomPosition, 66); n++;
  1965.         XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1966.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1967.         XtSetArg (args[n], XmNleftWidget, label[1]); n++;
  1968.         XtSetValues (text[1], args, n);
  1969.  
  1970.         /* geometry for text 2
  1971.         */
  1972.         XtSetArg (args[n], XmNtopAttachment, XmATTACH_POSITION); n++;
  1973.         XtSetArg (args[n], XmNtopPosition, 66); n++;
  1974.         XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
  1975.         XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
  1976.         XtSetArg (args[n], XmNleftWidget, label[2]); n++;
  1977.         XtSetArg (args[n], XmNbottomAttachment, XmATTACH_FORM); n++;
  1978.         XtSetValues (text[2], args, n);
  1979.  
  1980.  
  1981. -----------------------------------------------------------------------------
  1982. Subject: 61) TOPIC: PUSHBUTTON WIDGET
  1983.  
  1984. -----------------------------------------------------------------------------
  1985. Subject: 62) Why can't I use accelerators on buttons not in a menu?
  1986.  
  1987. Answer: It is apparently a difficult feature to implement, but OSF are
  1988. considering this for the future. It is problematic trying to use the Xt
  1989. accelerators since the Motif method interferes with this.  The workaround
  1990. suggested so far is to duplicate your non-menu button by a button in a menu
  1991. somewhere, which does have a menu-accelerator installed.  When the user
  1992. invokes what they think is the accelerator for the button they can see Motif
  1993. actually invokes the button on the menu that they can't see at the time.
  1994.  
  1995.  
  1996. -----------------------------------------------------------------------------
  1997. Subject: 63) TOPIC: LABEL WIDGET
  1998.  
  1999. -----------------------------------------------------------------------------
  2000. Subject: 64) How can I align the text in a label (button, etc) widget?
  2001.  
  2002. Answer: The alignment for the label widget is controlled by the resource
  2003. XmNalignment, and the default centers the text. Use this resource to change it
  2004. to left or right alignment.  However, when the label (or any descendant) is in
  2005. a row column, and XmNisAligned is True (the default), the row column aligns
  2006. text using its resource XmNentryAlignment. If you want simultaneous control
  2007. over all widgets use this, but otherwise turn XmNisAligned off and do it
  2008. individually.
  2009.  
  2010.  
  2011.  
  2012. -----------------------------------------------------------------------------
  2013. Subject: 65) Why doesn't label alignment work in a RowColumn?
  2014.  
  2015. Answer: RowColumn has a  resource XmNisAligned (default True) and and
  2016. XmNentryAlignment (default XmALIGNMENT_BEGINNING).  These control alignment of
  2017. the labelString in Labels and descendants. Set XmNisAligned to False to turn
  2018. this off.
  2019.  
  2020. -----------------------------------------------------------------------------
  2021. Subject: 66)  How can I set a multiline label?
  2022. [Last modified: September 92]
  2023.  
  2024. Answer: In .Xdefaults
  2025.  
  2026.       *XmLabel*labelString:             Here\nis\nthe\nLabel
  2027.  
  2028. This method does not seem to work in some of the older Motif 1.0 versions.
  2029.  
  2030. In code,
  2031.  
  2032.       char buf[128];
  2033.       XmString msg;
  2034.       sprintf(buf, "Here\nis\nthe\nLabel");
  2035.       msg = XmStringCreateLtoR(buf, XmSTRING_DEFAULT_CHARSET);
  2036.       XtSetArg (args[n], XmNlabelString, msg);
  2037.  
  2038. Gives a four line label, using the escape sequence \n for a newline.  However,
  2039. XmStringCreateLtoR() is obsoleted from version 1.1 on, and may disappear.
  2040. This is because it it is only in the AES as "trial-use" and has been proposed
  2041. for removal from the AES. Realistically, it will probably not be removed from
  2042. any backward compatible versions of Motif, but the potential is there.  If it
  2043. does disappear (or if you want to avoid using the non-AES compliant
  2044. XmSTRING_DEFAULT_CHARSET), try this from Jean-Philippe Martin-Flatin
  2045. <syj@ecmwf.co.uk>
  2046.  
  2047. #include <Xm/Xm.h>
  2048. #include <string.h>
  2049.  
  2050. /*-----------------------------------------------------
  2051.     Create a new XmString from a char*
  2052.  
  2053.     This function can deal with embedded 'newline' and
  2054.     is equivalent to the obsolete XmStringCreateLtoR,
  2055.     except it does not use non AES compliant charset
  2056.     XmSTRING_DEFAULT_CHARSET
  2057. ----------------------------------------------------*/
  2058. XmString xec_NewString(char *s)
  2059. {
  2060.     XmString xms1;
  2061.     XmString xms2;
  2062.     XmString line;
  2063.     XmString separator;
  2064.     char     *p;
  2065.     char     *t = XtNewString(s);   /* Make a copy for strtok not to */
  2066.                                     /* damage the original string    */
  2067.  
  2068.  
  2069.     separator = XmStringSeparatorCreate();
  2070.     p         = strtok(t,"\n");
  2071.     xms1      = XmStringCreateSimple(p);
  2072.  
  2073.     while (p = strtok(NULL,"\n"))
  2074.     {
  2075.         line = XmStringCreateSimple(p);
  2076.         xms2 = XmStringConcat(xms1,separator);
  2077.         XmStringFree(xms1);
  2078.         xms1 = XmStringConcat(xms2,line);
  2079.         XmStringFree(xms2);
  2080.         XmStringFree(line);
  2081.     }
  2082.  
  2083.     XmStringFree(separator);
  2084.     XtFree(t);
  2085.     return xms1;
  2086. }
  2087.  
  2088.  
  2089. Do not use XmStringCreateSimple() - it does not process the newline character
  2090. in the way you want.
  2091.  
  2092. In UIL, you have to explicitly create a compound string with a separator.
  2093. Here's what W. Scott Meeks suggests:
  2094.  
  2095. value nl : compound_string('', seperate=true);
  2096.  
  2097. object my_label : XmLabel
  2098. {
  2099.     arguments
  2100.     {
  2101.         XmNlabelString = 'Here' & nl & 'is' & nl & 'the' & nl & 'Label';
  2102.     };
  2103. };
  2104.  
  2105.  
  2106. -----------------------------------------------------------------------------
  2107. Subject: 67)  How can I have a vertical label?
  2108.  
  2109. Answer: Make a multiline label with one character per line, as in the last
  2110. question. There is no way to make the text rotated by 90 degrees though.
  2111.  
  2112.  
  2113. -----------------------------------------------------------------------------
  2114. Subject: 68)  How can I have a Pixmap in a Label?
  2115.  
  2116. Answer: From Bob Hays (bobhays@spss.com)
  2117.  
  2118.     Pixmap px_disarm, px_disarm_insens;
  2119.  
  2120.     Widget Label1;
  2121.     Pixel   foreground, background;
  2122.     Arg     args[4];
  2123.     Arg     arg[] = {
  2124.                 { XmNforeground, &foreground },
  2125.                 { XmNbackground, &background }
  2126.     };
  2127.  
  2128.     Label1 = XmCreateLabel ( Shell1, "Label1",
  2129.                                        (Arg *) NULL, (Cardinal) 0 );
  2130.     XtGetValues ( Label1, arg, XtNumber ( arg ) );
  2131.     px_disarm =
  2132.       XCreatePixmapFromBitmapData(display,
  2133.                                 DefaultRootWindow(display),
  2134.                                 mtn_bits, mtn_width, mtn_height,
  2135.                                 foreground,
  2136.                                 background,
  2137.                                 DefaultDepth(display,DefaultScreen(display)));
  2138.     px_disarm_insens =
  2139.       XCreatePixmapFromBitmapData(display,
  2140.                                 DefaultRootWindow(display),
  2141.                                 mtn_ins_bits, mtn_ins_width, mtn_ins_height,
  2142.                                 foreground,
  2143.                                 background,
  2144.                                 DefaultDepth(display,DefaultScreen(display)));
  2145.  
  2146.     n = 0;
  2147.     XtSetArg(args[n], XmNlabelType, XmPIXMAP);  n++;
  2148.     XtSetArg(args[n], XmNlabelPixmap, px_disarm);  n++;
  2149.     XtSetArg(args[n], XmNlabelInsensitivePixmap, px_disarm_insens ); n++;
  2150.     XtSetValues ( Label1, args, n );
  2151.     XtManageChild(Label1);
  2152.  
  2153. That will cause the foreground and background of your pixmap to be inherited
  2154. from the one that would be used by OSF/Motif when the label is displayed.  The
  2155. advantage is that this will utilize any resource values the user may have
  2156. requested without looking explicitly into the resource database.  And, you
  2157. will have a pixmap handy if the application insensitizes the label (without an
  2158. XmNlabelInsensitivePixmap your label will go empty if made insensitive).
  2159.  
  2160. [Bob's original code was for a PushButton. Just change all Label to PushButton
  2161. for them.]
  2162.  
  2163.  
  2164. -----------------------------------------------------------------------------
  2165. Subject: 69) TOPIC: DRAWING AREA WIDGET
  2166.  
  2167. -----------------------------------------------------------------------------
  2168. Subject: 70) How can I send an expose event to a Drawing Area widget?  (or any
  2169. other, come to that). I want to send an expose event so that it will redraw
  2170. itself.
  2171.  
  2172. Answer: Use the Xlib call
  2173.  
  2174.         XClearArea(XtDisplay(w), XtWindow(w), 0, 0, 0, 0, True)
  2175.  
  2176. This clears the widget's window and generates an expose event in doing so.
  2177. The widgets expose action will then redraw it.  This uses a round trip
  2178. request.  An alternative, without the round trip is
  2179.  
  2180. from orca!mesa!rthomson@uunet.uu.net  (Rich Thomson):
  2181.  
  2182.     Widget da;
  2183.     XmDrawingAreaCallbackStruct da_struct;
  2184.  
  2185.     da_struct.reason = XmCR_EXPOSE;
  2186.     da_struct.event = (XEvent *) NULL;
  2187.     da_struct.window = XtWindow(da);
  2188.  
  2189.     XtCallCallbacks(da, XmNexposeCallback, (XtPointer) da_struct);
  2190.  
  2191.  
  2192. -----------------------------------------------------------------------------
  2193. Subject: 71) How can I know when a DrawingArea has been resized?  It generates
  2194. an expose event whn it is enlarged, but not when it is shrunk.
  2195.  
  2196. Answer: Use the resize callback.
  2197.  
  2198. -----------------------------------------------------------------------------
  2199. Subject: 72) TOPIC: MENUS
  2200.  
  2201. -----------------------------------------------------------------------------
  2202. Subject: 73) What can I put inside a menu bar?
  2203.  
  2204. Answer: You can only put cascade buttons in menu bars. No pushbuttons, toggle
  2205. buttons or gadgets are allowed. When you create a pulldown menu with parent a
  2206. menu bar, its real parent is a shell widget.
  2207.  
  2208. -----------------------------------------------------------------------------
  2209. Subject: 74) Can I have a cascade button without a submenu in a pulldown menu?
  2210.  
  2211. Answer: Yes you can. A cascade button has an activate callback which is called
  2212. when you click on it and it doesn't have a submenu. It can have a mnemonic,
  2213. but keyboard traversal using the arrow keys in the menu will skip over it.
  2214.  
  2215. -----------------------------------------------------------------------------
  2216. Subject: 75) Should I have a cascade button without a submenu in a pulldown
  2217. menu?
  2218.  
  2219. Answer: No. This is forbidden by the style guide. Technically you can do it
  2220. (see previous question) but if you do it will not be Motif style compliant.
  2221. This is unlikely to change - if a "button" is important enough to be in a
  2222. pulldown menu bar with no pulldown, it should be a button elsewhere.  (Mind
  2223. you, you won't be able to put accelerators on it elsewhere though.)
  2224.  
  2225. -----------------------------------------------------------------------------
  2226. Subject: 76)  What is the best way to create popup menus?
  2227. [Last modified: August 92]
  2228.  
  2229. Susan Murdock Thompson (from OSF): In general, create a popupMenu as the child
  2230. from which you will be posting it from (ie: if you have a bulletinBoard with a
  2231. PushButton in it and want MB2 on the pushButton to post the popupMenu, create
  2232. the popupMenu as a child of the pushButton).  [This parent-child relationship
  2233. seems to make a big difference in the behavior of the popups.]  Add an event
  2234. handler to handle buttonPress events.  You'll need to check for the correct
  2235. button (what you've specified menuPost to be) before posting the menu.
  2236.  
  2237. To create a popup that can be accessible from within an entire client window,
  2238. create it as the child of the top-most widget (but not the shell) and add
  2239. event handlers for the top-most widget and children widgets.
  2240.  
  2241. ie:
  2242.  
  2243. {
  2244.   ....
  2245.  
  2246.   XtManageChild(rc=XmCreateRowColumn(Shell1, "rc", NULL, 0));
  2247.   XtManageChild(label = XmCreateLabel(rc, "label", NULL, 0));
  2248.   XtManageChild(text = XmCreateText(rc, "text", NULL, 0));
  2249.   XtManageChild(pushbutton = XmCreatePushButton(rc, "pushbutton", NULL, 0));
  2250.  
  2251.   n = 0;
  2252.   XtSetArg(args[n], XmNmenuPost, "<Btn3Down>"); n++;
  2253.   popup = XmCreatePopupMenu(rc, "popup", args, n);
  2254.  
  2255.   XtAddEventHandler(rc, ButtonPressMask, False, PostMenu3, popup);
  2256.   XtAddEventHandler(text, ButtonPressMask, False, PostMenu3, popup);
  2257.   XtAddEventHandler(label, ButtonPressMask, False, PostMenu3, popup);
  2258.   XtAddEventHandler(pushbutton, ButtonPressMask, False, PostMenu3, popup);
  2259.  
  2260.   XtManageChild(m1 = XmCreatePushButton(popup, "m1", NULL, 0));
  2261.   XtManageChild(m2 = XmCreatePushButton(popup, "m2", NULL, 0));
  2262.   XtManageChild(m3 = XmCreatePushButton(popup, "m3", NULL, 0));
  2263.  
  2264.   XtAddCallback(m1, XmNactivateCallback, SayCB, "button M1");
  2265.   XtAddCallback(m2, XmNactivateCallback, SayCB, "button M2");
  2266.   XtAddCallback(m3, XmNactivateCallback, SayCB, "button M3");
  2267.   ...
  2268. }
  2269.  
  2270. /* where PostMenu3 is ... */
  2271.  
  2272. PostMenu3 (w, popup, event)
  2273. Widget w;
  2274. Widget popup;
  2275. XButtonEvent * event;
  2276. {
  2277.   printf("menuPost = 3, button %d0, event->button);
  2278.  
  2279.   if (event->button != Button3)
  2280.     return;
  2281.   XmMenuPosition(popup, event);
  2282.   XtManageChild(popup);
  2283. }
  2284.  
  2285.  
  2286.  
  2287. -----------------------------------------------------------------------------
  2288. Subject: 77)  How do popup menus work?
  2289. [Last modified: August 92]
  2290.  
  2291. Answer:
  2292.  
  2293. When a popup menu is created as the child of a widget the menu system installs
  2294. a translation on the parent of the popup and descendants with an action which:
  2295. (1) when 3-rd button (the default for the menuPost resource) is pressed the
  2296. cursor changes and the mouse is grabbed for 5 seconds; (2) disables event
  2297. handlers on the descendants and the handlers are never called; (3) an event
  2298. handler installed on the parent works fine.
  2299.  
  2300. It is done so that the correct event handler will (in fact) be called.  There
  2301. is a grab with owner_events true.  The grab is released by a timer,  but
  2302. normally the posted menu shell puts up it's own grab.
  2303.  
  2304. If you only have widgets then you can use the subwindow field in the event to
  2305. identify the original widget.  If you have gadgets or other data that you want
  2306. to change the menu for (or use a specific menu for) then you must do a walk of
  2307. the parent's children to find the best match.
  2308.  
  2309. One thing to beware of is that even with the grab,  because the menu system
  2310. does a grab with owner events true, you must either have an event handler, or
  2311. nothing that will use the event on each widget in the hierarchy of the menu's
  2312. parent.  If a child widget has another event handler for button down, it may
  2313. swallow the event and do something else.
  2314.  
  2315.  
  2316.  
  2317. -----------------------------------------------------------------------------
  2318. Subject: 78)  Should I use translation tables or actions for popup menus?
  2319. [Last modified: August 92]
  2320.  
  2321. Answer: The original goal of popupMenus was that the user would not have to
  2322. specify an event handler to manage popupMenus; however, that did not become
  2323. reality.  Larry Rogers wrote:
  2324.  
  2325. > There appear to be two ways to manage popup menus.  I
  2326. > am curious what the correct way would be:
  2327.  
  2328. > 1.  Change the translation table of the widget with the
  2329. >    popup child to popup the menu.  Note that this does
  2330. >    not currently working for many widgets, because aug-
  2331. >    menting their translations, even for augment breaks
  2332. >    the widget.
  2333.  
  2334. > 2.  Add an event handler at creation to the widget; then
  2335. >    determine if the event that caused the event handler
  2336. >    to be called is the current button being used by the
  2337. >    menu as its activation button.
  2338.  
  2339. Susan Murdock Thompson (from OSF) replied: *Theoretically, you should be able
  2340. to do both.*  Our documentation says use event handlers.  Our tests for the
  2341. toolkit use event handlers and for UIL use translations.  (Although I tried an
  2342. event handler with a UIL test and it works).
  2343.  
  2344. -----------------------------------------------------------------------------
  2345. Subject: 79)  What are the known bugs in popup menus?
  2346. [Last modified: August 92]
  2347.  
  2348. Answer: As at Motif 1.1.4, the bugs for which an OSF PIR exists are:
  2349.  
  2350.    (3)  Menus not being sticky (ie: posted on a Btn CLICK)  [ Note:this
  2351.         problem occurs with OptionMenus as well]  (PIR 3435)
  2352.  
  2353.    (6)  Destroying a widget with an associated popupMenu results in
  2354.         "Warning: Attempt to remove non-existant passive grab"         (PIR
  2355. 2972)
  2356.  
  2357.    (7)  Current documentation insufficient regarding requirements for
  2358.         success in using PopupMenus.  (PIR 3433)
  2359.  
  2360.  
  2361. -----------------------------------------------------------------------------
  2362. Subject: 80)  Can I have multiple popup menus on the same widget?
  2363. [Last modified: August 92]
  2364.  
  2365. Answer: If you want to have several popups (activated by different mouse
  2366. buttons) on the same widget..., well, that doesn't work yet.
  2367.  
  2368. If you want to have several popups on different children... that works.  But
  2369. don't put a popup on the parent (manager) widget, or it will rule!
  2370.  
  2371.  
  2372.  
  2373. -----------------------------------------------------------------------------
  2374. Subject: 81) TOPIC: INPUT FOCUS
  2375.  
  2376. -----------------------------------------------------------------------------
  2377. Subject: 82) How can I direct the keyboard input to a particular widget?
  2378.  
  2379. Answer: In Motif 1.1 call XmProcessTraversal(target, XmTRAVERSE_CURRENT).  The
  2380. widget (and all of its ancestors) does need to be realized BEFORE you call
  2381. this. Otherwise it has no effect.  XmProcessTraversal is reported to have many
  2382. bugs, so it may not work right.  A common occurrence is that it doesn't move
  2383. to the widget, but if you call XmProcessTraversal *twice* in a row, it will.
  2384. If you can't get it to work, try this from Kee Hinckley:
  2385.  
  2386.     // This insane sequence is as follows:
  2387.     //      On manage set up a focus callback
  2388.     //      On focus callback set up a timer (and get rid of focus callback!)
  2389.     //      On timer set the focus (which only works if the parent
  2390.     //      has the focus,
  2391.     //      which is why we went through all of this garbage)
  2392.     // There may be a better way, but I haven't time to try it now.
  2393.     //
  2394.     static void focusTO(void *data, XtIntervalId *) {
  2395.         XmProcessTraversal((Widget) data, XmTRAVERSE_CURRENT);
  2396.     }
  2397.  
  2398.     static void focusCB(Widget w, XtPointer data, XtPointer) {
  2399.         XtRemoveCallback(w, XmNfocusCallback, focusCB, data);
  2400.         XtAppAddTimeOut(XtWidgetToApplicationContext(w), 0, focusTO, data);
  2401.     }
  2402.  
  2403.     void OmXSetFocus(Widget parent, Widget w) {
  2404.         XtAddCallback(parent, XmNfocusCallback, focusCB, w);
  2405.     }
  2406.  
  2407.  
  2408. In Motif 1.0 call the undocumented _XmGrabTheFocus(target).
  2409.  
  2410. Do not use the X or Xt calls such as XtSetKeyboardFocus since this bypasses
  2411. the Motif traversal layer and can cause it to get confused.  This can lead to
  2412. odd keyboard behaviour elsewhere in your application.
  2413.  
  2414. -----------------------------------------------------------------------------
  2415. Subject: 83)  How can I have a modal dialog which has to be answered before
  2416. the application can continue?
  2417. [Last modified: July 92]
  2418.  
  2419. Answer: The answer depends on whether you are using the Motif window manager
  2420. mwm or not.  Test for this by XmIsMotifWMRunning.
  2421.  
  2422. The window manager mwm knows how to control event passing to dialog widgets
  2423. declared as modal. If the dialog is set to application modal, then no
  2424. interaction with the rest of the application can occur until the dialog is
  2425. destroyed or unmanaged.
  2426.  
  2427. Use the appropriate code in the following program.  There is followup
  2428. discussion after the program.
  2429.  
  2430.  
  2431. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  2432.  * This program is freely distributable without licensing fees and
  2433.  * is provided without guarantee or warranty expressed or implied.
  2434.  * This program is -not- in the public domain.  This program is
  2435.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  2436.  */
  2437.  
  2438. /*
  2439.  * ask_user.c -- create a pushbutton that posts a dialog box
  2440.  * that asks the user a question that requires an immediate
  2441.  * response.  The function that asks the question actually
  2442.  * posts the dialog that displays the question, waits for and
  2443.  * returns the result.
  2444.  */
  2445. #include <X11/Intrinsic.h>
  2446. #include <Xm/DialogS.h>
  2447. #include <Xm/SelectioB.h>
  2448. #include <Xm/RowColumn.h>
  2449. #include <Xm/MessageB.h>
  2450. #include <Xm/PushBG.h>
  2451. #include <Xm/PushB.h>
  2452.  
  2453. XtAppContext app;
  2454.  
  2455. #define YES 1
  2456. #define NO  2
  2457.  
  2458. /* main() --create a pushbutton whose callback pops up a dialog box */
  2459. main(argc, argv)
  2460. char *argv[];
  2461. int argc;
  2462. {
  2463.     Widget parent, button, toplevel;
  2464.     XmString label;
  2465.     void pushed();
  2466.  
  2467.     toplevel = XtAppInitialize(&app, "Demos",
  2468.         NULL, 0, &argc, argv, NULL, NULL, 0);
  2469.  
  2470.     label = XmStringCreateSimple("/bin/rm *");
  2471.     button = XtVaCreateManagedWidget("button",
  2472.         xmPushButtonWidgetClass, toplevel,
  2473.         XmNlabelString,          label,
  2474.         NULL);
  2475.     XtAddCallback(button, XmNactivateCallback,
  2476.         pushed, "Remove Everything?");
  2477.     XmStringFree(label);
  2478.  
  2479.     XtRealizeWidget(toplevel);
  2480.     XtAppMainLoop(app);
  2481. }
  2482.  
  2483. /* pushed() --the callback routine for the main app's pushbutton. */
  2484. void
  2485. pushed(w, question)
  2486. Widget w;
  2487. char *question;
  2488. {
  2489.     if (AskUser(w, question) == YES)
  2490.         puts("Yes");
  2491.     else
  2492.         puts("No");
  2493. }
  2494.  
  2495. /*
  2496.  * AskUser() -- a generalized routine that asks the user a question
  2497.  * and returns the response.
  2498.  */
  2499. AskUser(parent, question)
  2500. char *question;
  2501. {
  2502.     static Widget dialog;
  2503.     XmString text, yes, no;
  2504.     static int answer;
  2505.     extern void response();
  2506.  
  2507.     answer = 0;
  2508.     if (!dialog) {
  2509.         dialog = XmCreateQuestionDialog(parent, "dialog", NULL, 0);
  2510.         yes = XmStringCreateSimple("Yes");
  2511.         no = XmStringCreateSimple("No");
  2512.         XtVaSetValues(dialog,
  2513.             XmNdialogStyle,        XmDIALOG_APPLICATION_MODAL,
  2514.             XmNokLabelString,      yes,
  2515.             XmNcancelLabelString,  no,
  2516.             NULL);
  2517.         XtSetSensitive(
  2518.             XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON), False);
  2519.         XtAddCallback(dialog, XmNokCallback, response, &answer);
  2520.         XtAddCallback(dialog, XmNcancelCallback, response, &answer);
  2521.         /* if the user interacts via the system menu: */
  2522.         XtAddCallback(dialog, XmNpopdownCallback, response, &answer);
  2523.     }
  2524.     text = XmStringCreateSimple(question);
  2525.     XtVaSetValues(dialog,
  2526.         XmNmessageString,      text,
  2527.         NULL);
  2528.     XmStringFree(text);
  2529.     XtManageChild(dialog);
  2530.     XtPopup(XtParent(dialog), XtGrabNone);
  2531.  
  2532.     /* while the user hasn't provided an answer, simulate XtMainLoop.
  2533.      * The answer changes as soon as the user selects one of the
  2534.      * buttons and the callback routine changes its value.  Don't
  2535.      * break loop until XtPending() also returns False to assure
  2536.      * widget destruction.
  2537.      */
  2538.     while (answer == 0 || XtAppPending(app))
  2539.         XtAppProcessEvent(app, XtIMAll);
  2540.     return answer;
  2541. }
  2542.  
  2543. /* response() --The user made some sort of response to the
  2544.  * question posed in AskUser().  Set the answer (client_data)
  2545.  * accordingly and destroy the dialog.
  2546.  */
  2547. void
  2548. response(w, answer, reason)
  2549. Widget w;
  2550. int *answer;
  2551. XmAnyCallbackStruct *reason;
  2552. {
  2553.     switch (reason->reason) {
  2554.         case XmCR_OK:
  2555.             *answer = YES;
  2556.             break;
  2557.         case XmCR_CANCEL:
  2558.             *answer = NO;
  2559.             break;
  2560.         default:
  2561.             *answer = NO;
  2562.             return;
  2563.     }
  2564. }
  2565.  
  2566.  
  2567.  
  2568. If you aren't running a window manager that acknowledges this hint, then you
  2569. may have to grab the pointer (and keyboard) yourself to make sure the user
  2570. doesn't interact with any other widget.  Change the grab flag in XtPopup to
  2571. XtGrabExclusive, and XtRemoveGrab(XtParent(w)) to the response() function.
  2572.  
  2573.  
  2574. -----------------------------------------------------------------------------
  2575. Subject: 84) TOPIC: MEMORY AND SPEED
  2576.  
  2577. -----------------------------------------------------------------------------
  2578. Subject: 85)  Why does my application grow in size?
  2579.  
  2580. Answer: Motif 1.0 has many memory leaks, particularly in XmString
  2581. manipulation.  Switch to Motif 1.1.
  2582.  
  2583. Answer: The Intrinsics have a memory leak in accelerator table management, and
  2584. Motif uses this heavily.  Avoid this by mapping/unmapping widgets rather than
  2585. creating/destroying them, or get  X11R4 fix-15/16/17.
  2586.  
  2587. Answer: The server may grow in size due to its own memory leaks.  Switch to a
  2588. later server.
  2589.  
  2590. Answer: You are responsible for garbage collection in `C'.  Some common cases
  2591. where a piece of memory becomes garbage are
  2592.  
  2593.  a.  Memory is allocated by Motif for XmStrings by the functions
  2594.      XmStringConcat, XmStringCopy, XmStringCreate, XmStringCreateLtoR,
  2595.      XmStringCreateSimple, XmStringDirectionCreate, XmStringNConcat,
  2596.      XmStringNCopy, XmStringSegmentCreate, and XmStringSeparatorCreate.  The
  2597.      values returned by these functions should be freed using XmStringFree
  2598.      when they are no longer needed.
  2599.  
  2600.  b.  Memory is allocated by Motif for ordinary character strings (of type
  2601.      String) by Motif in XmStringGetLtoR, XmStringGetNextComponent, and
  2602.      XmStringGetNextSegment. After using the string, XtFree() it. [Note that
  2603.      XmStrings and Strings are two different data types.  XmStrings are
  2604.      XmStringFree'd, Strings are XtFree'd.]
  2605.  
  2606.  c.  If you have set the label (an XmString) in a label, pushbutton, etc
  2607.      widget, free it after calling XtSetValues() or the widget creation
  2608.      routine by XmStringFree().
  2609.  
  2610.  d.  If you have set text in a text widget, the text widget makes its own
  2611.      copy.  Unless you have a use for it, there is no need to keep your own
  2612.      copy.
  2613.  
  2614.  e.  If you have set the strings in a list widget the list widget makes its
  2615.      own copy.  Unless you have a use for it, there is no need to keep your
  2616.      own copy.
  2617.  
  2618.  f.  When you get the value of a single compound string from a Widget e.g.
  2619.      XmNlabelString, XmNmessageString, ... Motif gives you a copy of its
  2620.      internal value.  You should XmStringFree this when you have finished with
  2621.      it.
  2622.  
  2623.  g.  On the other hand, when you get a value of a Table e.g. XmStringTable for
  2624.      a List, you get a *pointer* to the internal Table, and should not free
  2625.      it.
  2626.  
  2627.  h.  When you get the value of the text in a widget by XmTextGetString or from
  2628.      the resource XmNvalue, you get a copy of the text.  You should XtFree
  2629.      this when you have finished with it.
  2630.  
  2631. Answer: From Josef Nelissen: at least in Motif 1.1.4, X11R4 on a HP 720, the
  2632. XmText/XmTextFieldSetString() functions have a memory leak.  The old
  2633. value/contents of the Widget isn't freed correctly.  To work around this bug,
  2634. one should use a XmText Widget (in single-line-mode) instead of a XmTextField
  2635. Widget (the solution fails with XmTextField Widgets !) and replace any
  2636.  
  2637.        XmTextSetString(text_widget, str);
  2638.  
  2639. by
  2640.  
  2641.        XmTextReplace(text_widget, (XmTextPosition) 0,
  2642.                      XmTextGetLastPosition(text_widget), str);
  2643.  
  2644.  
  2645. -----------------------------------------------------------------------------
  2646. Subject: 86) Why does my application take a long time to start up?
  2647.  
  2648. Answer: You are probably creating too many widgets at startup time.  Delay
  2649. creating them until needed.  If you have a large number of resources in text
  2650. files (such as in app-defaults), time may be spent reading and parsing it.
  2651.  
  2652. -----------------------------------------------------------------------------
  2653. Subject: 87) My application is running too slowly. How can I speed it up?
  2654.  
  2655. Answer: Use the R4 rather than R3 server.  It is much faster.
  2656.  
  2657. Answer: The standard memory allocator is not well tuned to Motif, and can
  2658. degrade performance.  Use a better allocator.  e.g. with SCO Unix, link with
  2659. libmalloc.a; use the allocator from GNU emacs; use the allocator from Perl.
  2660.  
  2661. Answer: Avoid lots of widget creation and destruction.  It fragments memory
  2662. and slows everything down.  Popup/popdown, manage/unmanage instead.
  2663.  
  2664. Answer: Set mappedWhenManaged to FALSE, and then call XtMapWidget()
  2665. XtUnmapWidget() rather than managing.
  2666.  
  2667. Answer: Get more memory - your application, the server and the Operating
  2668. System may be spending a lot of time being swapped.
  2669.  
  2670. Answer: If you are doing much XmString work yourself, such as heavy use of
  2671. XmStringCompare, speed may deteriorate due to the large amount of internal
  2672. conversions and malloc'ing.  Try using XmStringByteCompare if appropriate or
  2673. ordinary Ascii strings if you can.
  2674.  
  2675.  
  2676.  
  2677. -----------------------------------------------------------------------------
  2678. END OF PART THREE
  2679.  
  2680.  
  2681. -----------------------------------------------------------------------------
  2682. Subject: 88) TOPIC: XMSTRING
  2683.  
  2684. -----------------------------------------------------------------------------
  2685. Subject: 89) How can I get the Ascii text out of an XmString?
  2686.  
  2687. Answer: To get the first line of text from a string created left-to-right
  2688.  
  2689.  
  2690.         char *str;
  2691.         XmString xmstr;
  2692.  
  2693.         /* stuff to create xmstr */
  2694.         ...
  2695.  
  2696.         /* set str to point to the text */
  2697.         XmStringGetLtoR(xmstr, XmSTRING_DEFAULT_CHARSET, &str);
  2698.         /* use the string */
  2699.         ...
  2700.  
  2701.         /* and reclaim space */
  2702.         XtFree(str);
  2703.  
  2704.  
  2705. -----------------------------------------------------------------------------
  2706. Subject: 90) When can XmStrings used as resources be freed?
  2707.  
  2708. Answer: The policy OSF have been trying to enforce is that if you set an
  2709. XmString or XmStringTable resource, the application is responsible for freeing
  2710. the XmStrings used because the widget makes a copy.  If you get an XmString
  2711. resource, then the application must free the value gotten.  If you get an
  2712. XmStringTable, then the application should NOT free the value gotten.  If the
  2713. application wants to manipulate it, it should make a copy first. This policy
  2714. appears to be implemented progressively, so may be less true for Motif 1.0
  2715. than 1.1.
  2716.  
  2717. -----------------------------------------------------------------------------
  2718. Subject: 91) Why doesn't XmStringGetNextSegment() work properly?
  2719.  
  2720. Answer: The documentation in Motif 1.0 is in error. Instead of
  2721.  
  2722.         XmStringGetnextSegment(context, ...)
  2723.         XmStringContext * context;
  2724.  
  2725. it should be
  2726.  
  2727.         XmStringGetnextSegment(context, ...)
  2728.         XmStringContext context;
  2729.  
  2730. i.e. with no indirection.
  2731.  
  2732. -----------------------------------------------------------------------------
  2733. Subject: 92) TOPIC: DIALOGS
  2734.  
  2735. -----------------------------------------------------------------------------
  2736. Subject: 93) How do I stop my dialog disappearing when I press the help
  2737. button?
  2738.  
  2739. Answer: Bulletin board has the resource autoUnmanage which defaults to True.
  2740. This unmanages the widget when any button child is activated - including the
  2741. help button.  Set this to False to stop it disappearing. Note that you then
  2742. have to unmanage the bulletin board yourself when any other button is
  2743. activated.
  2744.  
  2745. -----------------------------------------------------------------------------
  2746. Subject: 94) How do I make my own dialog?  I want a dialog with my own set of
  2747. buttons that stretch and shrink like the ones in e.g. PromptDialog and its own
  2748. contents.
  2749.  
  2750. Answer: Start off with say a PromptDialog. Unmanage the buttons you don't want
  2751. or manage the Apply button if you want another. Unmanage the other bits of the
  2752. selection box you don't want. You can add another WorkArea child to the
  2753. selection box for any extra stuff you want.
  2754.  
  2755.     /* Copyright 1990, Kee Hinckley and Brian Holt Hawthorne */
  2756.     /* Permission granted for any use, provided this copyright */
  2757.     /* notice is maintained. */
  2758.  
  2759.     /* Create a dialog box */
  2760.     argcount = setArgs(&args, XmNautoUnmanage, False, NULL);
  2761.     SomeDialog = XmCreatePromptDialog(mainShell, "someDialog", args, argcount);
  2762.  
  2763.     /* Now get rid of the things we don't want */
  2764.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_SELECTION_LABEL);
  2765.     XtUnmanageChild(child);
  2766.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_TEXT);
  2767.     XtUnmanageChild(child);
  2768.  
  2769.     /* set the callbacks, and make sure the buttons we want are there */
  2770.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_OK_BUTTON);
  2771.     XtAddCallback(child, XmNactivateCallback, callSomeFunc, someArg);
  2772.     XtAddCallback(child, XmNactivateCallback, unManage, SomeDialog);
  2773.     XtManageChild(child);
  2774.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_APPLY_BUTTON);
  2775.     XtAddCallback(child, XmNactivateCallback, callSomeFunc, someOtherArg);
  2776.     XtManageChild(child);
  2777.     child = XmSelectionBoxGetChild(SomeDialog, XmDIALOG_CANCEL_BUTTON);
  2778.     XtAddCallback(child, XmNactivateCallback, dialogUnmanage, SomeDialog);
  2779.     XtManageChild(child);
  2780.  
  2781.     /* Add a new work area. This can be any manager. */
  2782.     child = XmCreateForm(SomeDialog, "someForm", NULL, 0);
  2783.     XtManageChild(child);
  2784.  
  2785.     /* and fill it up... */
  2786.     something = doYourStuff(child);
  2787.  
  2788.  
  2789.  
  2790. -----------------------------------------------------------------------------
  2791. Subject: 95) How come the title bars for my dialogs now have "_popup" or "<-
  2792. popup" concatenated onto the widget name?
  2793.  
  2794.  
  2795. Answer: Motif 1.0.3 (?) "fixed" things such that title bars without an
  2796. explicit dialogTitle setting use the widget name with "_popup" or whatever
  2797. added on.  Set the dialogTitle resource explicitly if you don't want this new
  2798. default naming scheme.
  2799.  
  2800. -----------------------------------------------------------------------------
  2801. Subject: 96) How can I force a dialog window to display?  I manage a "working"
  2802. dialog, and do some computing, but the dialog window appears blank until the
  2803. work has finished.  How can I force it to be displayed?
  2804.  
  2805. Answer: Use this.  (David Brooks, Systems Engineering, Open Software
  2806. Foundation)
  2807.  
  2808. /*
  2809.  * This procedure will ensure that, if a dialog window is being mapped,
  2810.  * its contents become visible before returning.  It is intended to be
  2811.  * used just before a bout of computing that doesn't service the display.
  2812.  * You should still call XmUpdateDisplay() at intervals during this
  2813.  * computing if possible.
  2814.  *
  2815.  * The monitoring of window states is necessary because attempts to map
  2816.  * the dialog are redirected to the window manager (if there is one) and
  2817.  * this introduces a significant delay before the window is actually mapped
  2818.  * and exposed.  This code works under mwm, twm, uwm, and no-wm.  It
  2819.  * doesn't work (but doesn't hang) with olwm if the mainwindow is iconified.
  2820.  *
  2821.  * The argument to ForceDialog is any widget in the dialog (often it
  2822.  * will be the BulletinBoard child of a DialogShell).
  2823.  */
  2824.  
  2825. ForceDialog(w)
  2826.      Widget w;
  2827. {
  2828.   Widget diashell, topshell;
  2829.   Window diawindow, topwindow;
  2830.   Display *dpy;
  2831.   XWindowAttributes xwa;
  2832.   XEvent event;
  2833.   XtAppContext cxt;
  2834.  
  2835. /* Locate the shell we are interested in.  In a particular instance, you
  2836.  * may know these shells already.
  2837.  */
  2838.  
  2839.   for (diashell = w;
  2840.        !XtIsShell(diashell);
  2841.        diashell = XtParent(diashell))
  2842.     ;
  2843.  
  2844. /* Locate its primary window's shell (which may be the same) */
  2845.  
  2846.   for (topshell = diashell;
  2847.        !XtIsTopLevelShell(topshell);
  2848.        topshell = XtParent(topshell))
  2849.     ;
  2850.  
  2851.   if (XtIsRealized(diashell) && XtIsRealized(topshell)) {
  2852.     dpy = XtDisplay(topshell);
  2853.     diawindow = XtWindow(diashell);
  2854.     topwindow = XtWindow(topshell);
  2855.     cxt = XtWidgetToApplicationContext(diashell);
  2856.  
  2857. /* Wait for the dialog to be mapped.  It's guaranteed to become so unless... */
  2858.  
  2859.     while (XGetWindowAttributes(dpy, diawindow, &xwa),
  2860.            xwa.map_state != IsViewable) {
  2861.  
  2862. /* ...if the primary is (or becomes) unviewable or unmapped, it's
  2863.    probably iconified, and nothing will happen. */
  2864.  
  2865.       if (XGetWindowAttributes(dpy, topwindow, &xwa),
  2866.           xwa.map_state != IsViewable)
  2867.         break;
  2868.  
  2869. /* At this stage, we are guaranteed there will be an event of some kind.
  2870.    Beware; we are presumably in a callback, so this can recurse. */
  2871.  
  2872.       XtAppNextEvent(cxt, &event);
  2873.       XtDispatchEvent(&event);
  2874.     }
  2875.   }
  2876.  
  2877. /* The next XSync() will get an expose event if the dialog was unmapped. */
  2878.  
  2879.   XmUpdateDisplay(topshell);
  2880. }
  2881.  
  2882.  
  2883. -----------------------------------------------------------------------------
  2884. Subject: 97) How can I control placement of a popup widget?  Each time a popup
  2885. is created, it is placed in or over the middle of its parent.  How can I make
  2886. it obey the XmNx and XmNy values?
  2887.  
  2888. Answer: Set the resource XmNdefaultPosition for the popup to False.  Set the
  2889. position of the popup by the resource values of XmNx and XmNy.  Do not use
  2890. XtMoveWidget, as this is for widget writers only.  Here's a demo program from
  2891. Dan Heller:
  2892.  
  2893. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  2894.  * This program is freely distributable without licensing fees and
  2895.  * is provided without guarantee or warranty expressed or implied.
  2896.  * This program is -not- in the public domain.  This program is
  2897.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  2898.  */
  2899.  
  2900. /* map_dlg.c -- Use the XmNmapCallback to automatically position
  2901.  * a dialog on the screen.  Each time the dialog is displayed, it
  2902.  * is mapped down and to the right by 200 pixels in each direction.
  2903.  */
  2904. #include <Xm/MessageB.h>
  2905. #include <Xm/PushB.h>
  2906.  
  2907. /* main() --create a pushbutton whose callback pops up a dialog box */
  2908. main(argc, argv)
  2909. char *argv[];
  2910. {
  2911.     Widget toplevel, button;
  2912.     XtAppContext app;
  2913.     void pushed();
  2914.  
  2915.     toplevel = XtVaAppInitialize(&app, "Demos",
  2916.         NULL, 0, &argc, argv, NULL, NULL);
  2917.  
  2918.     button = XtCreateManagedWidget("button", xmPushButtonWidgetClass,
  2919.         toplevel, NULL, 0);
  2920.     XtAddCallback(button, XmNactivateCallback, pushed, "Hello World");
  2921.  
  2922.     XtRealizeWidget(toplevel);
  2923.     XtAppMainLoop(app);
  2924. }
  2925.  
  2926. /* callback function for XmNmapCallback.  Position dialog in 200 pixel
  2927.  * "steps".  When the edge of the screen is hit, start over.
  2928.  */
  2929. static void
  2930. map_dialog(dialog, client_data, cbs)
  2931. Widget dialog;
  2932. XtPointer client_data;
  2933. XmAnyCallbackStruct *cbs;
  2934. {
  2935.     static Position x, y;
  2936.     Dimension w, h;
  2937.  
  2938.     XtVaGetValues(dialog, XmNwidth, &w, XmNheight, &h, NULL);
  2939.     if ((x + w) >= WidthOfScreen(XtScreen(dialog)))
  2940.         x = 0;
  2941.     if ((y + h) >= HeightOfScreen(XtScreen(dialog)))
  2942.         y = 0;
  2943.     XtVaSetValues(dialog, XmNx, x, XmNy, y, NULL);
  2944.     x += 200, y += 200;
  2945. }
  2946.  
  2947. /* pushed() --the callback routine for the main app's pushbutton.
  2948.  * Create and popup a dialog box that has callback functions for
  2949.  * the Ok, Cancel and Help buttons.
  2950.  */
  2951. void
  2952. pushed(w, message)
  2953. Widget w;
  2954. char *message; /* The client_data parameter passed by XtAddCallback */
  2955. {
  2956.     Widget dialog;
  2957.     Arg arg[3];
  2958.     XmString t = XmStringCreateSimple(message);
  2959.     extern void response();
  2960.  
  2961.     XtSetArg(arg[0], XmNautoUnmanage, False);
  2962.     XtSetArg(arg[1], XmNmessageString, t);
  2963.     XtSetArg(arg[2], XmNdefaultPosition, False);
  2964.     dialog = XmCreateMessageDialog(w, "notice", arg, 3);
  2965.     XmStringFree(t);
  2966.  
  2967.     XtAddCallback(dialog, XmNmapCallback, map_dialog, NULL);
  2968.  
  2969.     XtManageChild(dialog);
  2970.     XtPopup(XtParent(dialog), XtGrabNone);
  2971. }
  2972.  
  2973.  
  2974. -----------------------------------------------------------------------------
  2975. Subject: 98) TOPIC: LANGUAGE BINDINGS
  2976.  
  2977. -----------------------------------------------------------------------------
  2978. Subject: 99)*  Is there a C++ binding for Motif?
  2979. [Last modified: November 92]
  2980.  
  2981.  
  2982. Answer: WWL is a library which defines C++ classes around X Toolkit Widgets.
  2983. It is intended to simplify the task of C++ code writers when using the Toolkit
  2984. by providing them with C++ objects, methods, type checking and several utility
  2985. functions and classes.
  2986.  
  2987. WWL has been tested under SunOs4.0.3 on sun3 and sun4, HPUX version 6.5 and
  2988. 7.0 and Ultrix 4.0 on DECstation 3100 and 5000. It is expected to work on most
  2989. other UNIX systems without too many problems.
  2990.  
  2991. WWL is distributed as a tar file with all the source, documentation and
  2992. example. The file is available using anonymous ftp from
  2993.  
  2994.         export.lcs.mit.edu (18.30.0.238   contrib/WWL-1.0.tar.Z
  2995.         lri.lri.fr (129.175.15.1)      pub/WWL-1.0.tar.Z
  2996.  
  2997.  
  2998. Answer: Rogue Wave Software has a C++ binding for Motif called View.h++.
  2999.  
  3000. "View.h++ is a complete C++ interface to OSF/Motif.  It doesn't just
  3001. encapsulate it, but also includes a set of classes that provide a level of
  3002. abstraction above Motif, thus simplifying menu and dialog creation, XmStrings,
  3003. XmFontLists, etc.  View.h++ supports a Model- View-Controller architecture,
  3004. allowing for an even more object-oriented interface design.  Includes a copy
  3005. of Rogue Wave's Tools.h++ (foundation class library)"
  3006.  
  3007. An object license is $795 "per seat" and a source code license is available
  3008. for $2,995 "per seat."  Rogue Wave also offers full support for View.h++.
  3009.  
  3010. It is currently available for Sun Sparc, IBM RS/6000, HP 9000/700 series, SCO,
  3011. Intel SVR4 ESIX.  Please call for Silicon Graphics and DEC Ultrix status.
  3012.  
  3013. For additional information, please contact:
  3014.  
  3015. Matt Steinauer
  3016. Rogue Wave Software, Inc.
  3017. P.O. Box 2328
  3018. Corvallis, OR 97339
  3019. Phone: (503)754-3010
  3020. Fax:   (503)757-6650
  3021.  
  3022. email:   matts@roguewave.com
  3023.  
  3024.  
  3025. Answer: From Andreas.Baecker@gmd.de: The GINA++ application framework contains
  3026. an encapsulation of the OSF/Motif widg et classes and the Xt functionality
  3027. into C++ classes. Its functionality is comparab le to that of the ULowell
  3028. binding and the WWL. Additionally, it provides an easy-to -use framework for
  3029. modeling new composite and primitive widget classes, plus an application
  3030. framework similar to ET++ or MacApp build on top of it. The binding may be
  3031. used independently from the framework classes. GINA++ is available through
  3032. anonymous ftp from ftp.gmd.de [129.26.8.90] in the directory /gmd/ginaplus.
  3033. Documentation about the Motif binding has been published in the X Resource
  3034. Journ al, Number 2, 1992, Pages 106-130. The binding compiles with AT&T C++
  3035. 2.1 and GNU G+ + 2.1 and has been tested on SunOS 4.1.[12], X11R4 and Motif
  3036. 1.1.3.
  3037.  
  3038. Answer: Motif++ is a library that defines C++ class "wrappers" for the widgets
  3039. defined in the OSF/Motif-1.1 widget library. Motif++ is also an application
  3040. toolkit that provides other tools in conjunction with the widget wrapper
  3041. classes.  It has support for the Xbae widget set, plus other widgets.  It has
  3042. Imake support, and lots of test files.
  3043.  
  3044. Motif++ is very similar to other public domain widget libraries such as The
  3045. Widget Wrapper Library (WWL) and the C++ Binding for OSF/Motif developed at
  3046. the Univeristy of Lowell. The two latter libraries are the result of much
  3047. larger efforts.
  3048.  
  3049. Availability:
  3050.  
  3051. Anonymous ftp at decuac.dec.com (192.5.214.1), directory /pub/X11,
  3052. file motif++.21.jul.92.tar.Z (855293 bytes).
  3053.  
  3054. For more information, contact Ronald van Loon (rvloon@cv.ruu.nl)
  3055.  
  3056.  
  3057. Answer: The Solbourne OI toolkit (not Motif) also has a C++ binding.
  3058.  
  3059. Answer: Doug Young has written a book "Object Oriented Programming with C++
  3060. and Motif", Prentice-Hall ISBN 0-13-630252-1 about using C++ without requiring
  3061. one of these toolkits.
  3062.  
  3063. -----------------------------------------------------------------------------
  3064. Subject: 100)+ How can I have a C++ member function in a callback?
  3065.  
  3066. [Last modified: November 92]
  3067.  
  3068. Answer: Motif++ has a nice tutorial summarising mechanisms. Doug Young's book
  3069. deals extensively with one of these. The problem is that you don't get the
  3070. object when you just use the function as a callback.  You need to pass the
  3071. object as a pointer through as the client_data.  (use "this" as the
  3072. client_data.) Then you can retrieve the object's address, and dereference from
  3073. there. For example (Leo O'Donnell, Email: leo@avs.com),
  3074.  
  3075.     class MyButton {
  3076.       public:
  3077.                 MyButton (Widget parent, const char *name) {
  3078.                     _button = XtVaCreateManagedWidget (
  3079.                         name, xmPushButtonWidgetClass, parent, NULL, 0);
  3080.                     XtAddCallback (
  3081.                         _button,
  3082.                         XmNactivateCallback,
  3083.                         &MyButton::activateCB,
  3084.                         (XtPointer) this);
  3085.                 }
  3086.                 ~MyButton () { XtDestoryWidget (_button); }
  3087.       private:
  3088.         Widget  _button;
  3089.         static  void activateCB (Widget, XtPointer, XtPointer);
  3090.     };
  3091.  
  3092.     void MyButton::activateCB (Widget, XtPointer thisBtn, XtPointer)
  3093.     {
  3094.         MyButton *btn = (MyButton *) thisBtn;
  3095.  
  3096.         // OK you've got the button instance now. Do some stuff with it!
  3097.     }
  3098.  
  3099.  
  3100.  
  3101. -----------------------------------------------------------------------------
  3102. Subject: 101)* Is there a Common Lisp binding for Motif?
  3103.  
  3104. [Last modified: November 92]
  3105.  
  3106. Answer: Try CLM. This includes a toolkit demon (in C) that takes a widget
  3107. description (with callbacks), and forks a new process for each Motif
  3108. application (which can be just a single menu, or whatever).  Lisp can then
  3109. continue running, with a separate lightweight lisp process handling the
  3110. connection & callbacks.  In North America & net environs, CLM-2.0beta is
  3111. available from export.lcs.mit.edu.
  3112.  
  3113. There is also CLIM, the Common Lisp Interface Manager. It provides access to
  3114. motif and other toolkits and window systems.  Here is some blurb: "Version 2.0
  3115. of the Common Lisp Interface Manager (CLIM) provides access to Motif. CLIM is
  3116. the emerging standard for GUI development in Common Lisp.  It offers a set of
  3117. high-level facilities that enable rapid construction of user interfaces.
  3118. Applications written using CLIM are portable across a variety of window
  3119. systems and toolkits.  For example, on the X window System, both Motif
  3120. (OSF/Motif) and Openlook (OLIT) are supported.  CLIM accesses the toolkit
  3121. directly rather than emulating the look and feel."
  3122.  
  3123. CLIM is available from a variety of Common Lisp vendors including Symbolics
  3124. and Franz Inc. (info@franz.com).
  3125.  
  3126.  
  3127. -----------------------------------------------------------------------------
  3128. Subject: 102)  Is there an Ada binding for Motif?
  3129.  
  3130. Answer:
  3131.  
  3132. From Todd W. Lainhart: Take a look at THINGS, a VAPI with Ada bindings that
  3133. was written by the US Air Force (SAC).  It's in the public domain, and
  3134. available from export or gatekeeper.dec.com.  It implements Motif or OL look-
  3135. and-feel. [I had a look and it seemed to be missing documentation - Jan]
  3136.  
  3137. From David Lewis: A company called Rational appears to be making an Xm
  3138. implementation.  Also GHG in Texas has most other Xlib and Xt bindings for
  3139. Ada.
  3140.  
  3141. From comp.windows.x FAQ: Ada bindings to Motif, explicitly, will eventually be
  3142. made available by the Jet Propulsion Laboratories, probably through the normal
  3143. electronic means.  Advance information can be obtained from
  3144. dsouleles@dsfvax.jpl.nasa.gov, who may respond as time permits.  Another set
  3145. of bindings for Motif is being done by the University of Lowell; information
  3146. is available from osfri@osf.org.[11/90]
  3147.  
  3148. TeleSoft has bindings for Motif, Xt and Xlib.  They are called TeleWindows.
  3149. Contact their customer support department for more information.
  3150.  
  3151.      TeleSoft
  3152.      5959 Cornerstone Court West
  3153.      San Diego, CA 92121-9891
  3154.      +1 619-457-2700
  3155.      +1 619-452-1334 Fax
  3156.  
  3157.      Email: adasales@telesoft.com (Sales)
  3158.             adasupport@telesoft.com (Customer Support)
  3159.  
  3160.  
  3161. TAE Plus will generate either Ada or C. Contact
  3162.  
  3163.         Goddard Space Flight Center
  3164.         TAE Suppport Office
  3165.         Code 522
  3166.         Attn: Arleen Yeager
  3167.         Greenbelt, MD  20771
  3168.         301-286-6034
  3169.         FTS 888-6034
  3170.  
  3171.         e-mail:  taeso@postman.gsfc.nasa.gov
  3172.  
  3173.         TELEMAIL from a NASA facility:      TELEMAIL outside of NASA:
  3174.         [TAESO/GSFCMAIL]GSFC                [TAESO/GSFCMAIL]GSFC/USA
  3175.         SPAN is 6162::TAESO
  3176.  
  3177. SA-Motif is a complete binding to X Window and Motif for the Ada; it is based
  3178. in part upon the SAIC/Unisys bindings. SA-Motif is available on the Sun3,
  3179. Sun4,  SCO, HPUX, and SGI IRIX. Info: Systems Engineering Research
  3180. Corporation, 2348 Leghorn Street, #202/Mountain View, CA 94043/1-800-Ada-SERC
  3181. (well!serc@apple.com).
  3182.  
  3183.  
  3184.  
  3185. -----------------------------------------------------------------------------
  3186. Subject: 103) TOPIC: SPECIFIC PLATFORMS
  3187.  
  3188. -----------------------------------------------------------------------------
  3189. Subject: 104) Is it easy to build Motif for a Sun?
  3190.  
  3191. Answer: No pattern has emerged to problems about compiling Motif on the Sun
  3192. (although people seem to have a lot of different minor problems), and many
  3193. reports are that it is straightforward. Read the Motif install instructions
  3194. (which often have specific reference to Sun installation), light the blue
  3195. touch paper and just standback. [My experience was that I had to add
  3196. -D_NO_PROTO for 1.1 on a Sparc OS 4.1, and that was all.  Others have added
  3197. STRINGS_ALIGNED and NO_REGEXP].
  3198.  
  3199.  
  3200. -----------------------------------------------------------------------------
  3201. Subject: 105) What compile errors/warnings might I get in both Sun 3 and Sun
  3202. 4?
  3203.  
  3204. Answer:
  3205.  
  3206.  
  3207. make: Warning: Too many rules defined for target
  3208. make: Warning: Too many rules defined for target
  3209. "callbacks.c", line 1530: warning: illegal combination of pointer
  3210. and integer, op =
  3211. "callbacks.c", line 1531: warning: illegal combination of pointer
  3212. and integer, op =
  3213. "callbacks.c", line 1532: warning: illegal combination of pointer
  3214. and integer, op =
  3215. "utils.c", line 73: warning: illegal combination of pointer and integer, op =
  3216. "utils.c", line 74: warning: illegal combination of pointer and integer, op =
  3217. "utils.c", line 122: warning: illegal combination of pointer and integer, op =
  3218. "utils.c", line 123: warning: illegal combination of pointer and integer, op =
  3219. "utils.c", line 191: warning: illegal combination of pointer and integer, op =
  3220. "utils.c", line 194: warning: illegal combination of pointer and integer, op =
  3221. "utils.c", line 195: warning: illegal combination of pointer and integer, op =
  3222. "utils.c", line 196: warning: illegal combination of pointer and integer, op =
  3223. "utils.c", line 316: warning: illegal combination of pointer and integer, op =
  3224. "utils.c", line 334: warning: illegal combination of pointer and integer, op =
  3225. "utils.c", line 338: warning: illegal combination of pointer and integer, op =
  3226. "utils.c", line 341: warning: illegal combination of pointer and integer, op =
  3227. "xmdialogs.c", line 838: warning: illegal combination of pointer
  3228. and integer, op =
  3229. "xmeditor.c", line 1152: warning: illegal combination of pointer
  3230. and integer, op =
  3231.  
  3232. These warning messages can be ignored. OSF is aware of these warnings.
  3233.  
  3234.  
  3235. -----------------------------------------------------------------------------
  3236. Subject: 106) On a Sun 3, what are the mwm startup error messages about?  I
  3237. get
  3238.  
  3239. mwm: Invalid accelerator specification on line 7 of
  3240.      specification string
  3241. mwm: Invalid accelerator specification on line 31 of
  3242.       configuration file
  3243.  
  3244.  
  3245. Answer: This is because some Sun keyboards do not have an F10 key and some sun
  3246. workstations which have an F10 key do not have X-servers which recognize it.
  3247. The F10 key is used by mwm.  If the machine does have an F10 key, the user
  3248. should use xmodmap to tell the server it exists.  Otherwise, change the
  3249. definition of the DefaultWindowMenu in /usr/lib/X11/system.mwmrc (after
  3250. installation) or in /lib/clients/mwm/system.mwmrc (before installation).
  3251. Change the accelerator of "Maximize" (it is "Alt<Key>F10)" to something else.
  3252. Also, you should change the definition of DEFAULTSYSTEMMENU in the file
  3253. /clients/mwm/WmResource.c in a similar fashion.  There is as yet no standard
  3254. redefinition for F10.
  3255.  
  3256.  
  3257.  
  3258. -----------------------------------------------------------------------------
  3259. Subject: 107) Are there problems making shared libraries on a Sun?
  3260.  
  3261. Answer: If you use the -pic option you may run out of offset table space.  use
  3262. the -PIC option instead.
  3263.  
  3264. You may get the message "ld.so: Undefined symbol: __XtInherit" when executing
  3265. UIL. There is a problem in shared library build when you compare a function
  3266. variable to a routine name, but don't call the routine.  Either, you can build
  3267. the Xt library nonshared, or you can put a reference to XtToolkitInitialize in
  3268. the UIL main program (or even include a module that references it).  The
  3269. routine doesn't even have to be called; it just has to be there.
  3270.  
  3271.  
  3272. -----------------------------------------------------------------------------
  3273. Subject: 108)  The OpenWindows server hangs when I popup a menu with Button 3.
  3274. [Last modified: August 92]
  3275.  
  3276. Answer: This is an OpenWindows problem, but if you have Motif source you can
  3277. fix your own applications. From Steve Sistare of Thinking Machines Corp.:
  3278. "Change the 2 calls to XtGrabButton in RowColumn.c such that ButtonReleaseMask
  3279. | ButtonPressMask is passed for the event mask.  Currently, only
  3280. ButtonReleaseMask is passed.  Also, change the owner_event argument to FALSE.
  3281. " This has not been fixed in Motif as at 1.1.5.
  3282.  
  3283. -----------------------------------------------------------------------------
  3284. Subject: 109) Has anyone made shared libraries on an IBM RS/6000?
  3285.  
  3286. Answer: From Sakari Jalovaara: There is a problem: Xm redefines VendorShell
  3287. and the AIX linker put _both_ Xm's and Xt's VendorShell into programs.  When
  3288. an AIX shared library is created as many references inside the library are
  3289. resolved as possible.  If the symbol vendorShellClassRec is defined in libXt
  3290. and referenced, say, from a function XtFoo() also in libXt, the "ld" run that
  3291. creates the shared library resolves the reference:
  3292.  
  3293.         XtFoo() -> vendorShellClassRec
  3294.  
  3295. Then I create the Motif library that has its own vendorShellClassRec and an
  3296. XmBar() function that uses it; libXm will also contain a resolved reference to
  3297. vendorShellClassRec:
  3298.  
  3299.         XmBar() -> vendorShellClassRec
  3300.  
  3301. Finally, I link a program that uses both XtFoo() and XmBar() and the program
  3302. will end up with _two_ independent "vendorShellClassRec"s:
  3303.  
  3304.         XtFoo() -> vendorShellClassRec [Xt version]
  3305.         XmBar() -> vendorShellClassRec [Xm version]
  3306.  
  3307. Instant schizo zaphod mode.  In reality, vendorShellClassRec is not referenced
  3308. from functions but from other widget class records.
  3309.  
  3310. I can't just pull Vendor.o out from the shared Xt (Vendor.o appears to define
  3311. the only external symbols redefined by libXm) because AIX shared libraries
  3312. apparently can't contain unresolved external references.  If I take out
  3313. Vendor.o I have to take out every other file that uses symbols defined there -
  3314. and then files that need those files, etc.  I tried it and ended up with three
  3315. or four object files in libXt and the res non-sharable.
  3316.  
  3317. I kludged around this by putting all of libXt (minus Vendor.o) into the shared
  3318. libXm.  It isn't a pretty solution but it works - and beats having a
  3319. statically linked two-megabyte "periodic" demo...
  3320.  
  3321.  
  3322. -----------------------------------------------------------------------------
  3323. Subject: 110)  What is the error  "Unaligned access in XmString" under Ultrix?
  3324.  
  3325. Answer: Compile  XmString.c with STRINGS_ALIGNED.
  3326.  
  3327. -----------------------------------------------------------------------------
  3328. Subject: 111) TOPIC: KEYSYMS
  3329.  
  3330. -----------------------------------------------------------------------------
  3331. Subject: 112)  What is causing the messages "unknown keysym osfDown..."?  It
  3332. happens when I run an application under Motif 1.1
  3333.  
  3334. Answer: There is an OSF supplied addition to the /usr/lib/X11/XKeysymDB file.
  3335. It is found on the release tape and should have been automatically installed
  3336. if the installation procedure was followed in the Release Notes.
  3337.  
  3338. You have to copy (or append) lib/Xm/XKeysymDB into /usr/lib/X11.  This may
  3339. require root permission.  It is not clear how to fix the problem if you can't
  3340. do this.  The error comes from Xt translation table parsing and can't be fixed
  3341. in Motif, so if you can't get root permission you may be stuck.  The file is
  3342. not copyrighted so you can install it on other systems.
  3343.  
  3344. If X has been built so that XKeysymDB is not in this directory, and you don't
  3345. know where it is looking, run 'strings libX11.a | grep XKeysymDB' to find the
  3346. path.
  3347.  
  3348. On a Sun running openwin with shared libraries, you may need to put the path
  3349. for the library containing XKeysymDB *first* in the path list in
  3350. LD_LIBRARY_PATH, or it may find the wrong XKeysymDB in the wrong directory.
  3351.  
  3352. XKeysymDB simply contains the registered keysym values for the OSF keysyms.
  3353. The OSF values are server-independent.  And, all registered keysyms will be
  3354. included in an XKeysymDB file to be shipped with X11R5.
  3355.  
  3356. In the meantime (till all systems are X11R5+), a list of the registered
  3357. keysyms can be found in the X11R4 release in mit/doc/Registry/Xregistry.
  3358.  
  3359.  
  3360.  
  3361. -----------------------------------------------------------------------------
  3362. Subject: 113) What happens if I can't install Motif Keysyms?
  3363.  
  3364. From: tessi!george@nosun.West.Sun.COM (George Mitchell)
  3365.  
  3366. Here's what appears to happen if you don't have XKeysymDB in place to define
  3367. OSF's virtual keysyms:
  3368.  
  3369. 1. At class initialize time, for a widget (such as XmText) that uses virtual
  3370. keysyms in its event translation table, all entries which refer to those
  3371. keysyms fail to parse correctly.  In the case of XmText, instead of ending up
  3372. with a translation table with roughly 90 entries, you end up with one that has
  3373. 29.
  3374.  
  3375. 2. XKeysymDB doesn't exist, so you'd assume that KeyPress events will get
  3376. translated to plain vanilla keysyms, right?  WRONG!  All Motif widgets install
  3377. a virtual keysym translator ANYWAY!  Consequently, the backspace key (for
  3378. example) gets translated to the keysym osfBackSpace.
  3379.  
  3380. 3. Therefore, if you augment or override your widget's translations with
  3381. translations that refer to plain vanilla BackSpace, they will never be
  3382. triggered, because you will NEVER see plain vanilla BackSpace, only
  3383. osfBackSpace.
  3384.  
  3385. 4. But you can't use osfBackSpace in an event translation entry, because you
  3386. don't have XKeysymDB installed!
  3387.  
  3388. Here's how I'm "dealing" with the problem right now: Motif installs its
  3389. virtual keysym translator by calling XtSetKeyTranslator every time a
  3390. VendorShell (or subclass) widget is created.  So every time I create a shell,
  3391. I immediately call XtSetKeyTranslator (display, XtTranslateKey) to restore the
  3392. default translator.  No more funny virtual keysyms!  Now I can reinstall non-
  3393. osfKeySym translations and have them work the way I expect.
  3394.  
  3395.  
  3396. -----------------------------------------------------------------------------
  3397. Subject: 114) Why has OSF introduced Keysyms into Motif 1.1?  They weren't
  3398. there in Motif 1.0.
  3399.  
  3400. Answer: From: ellis@osf.org
  3401.  
  3402. Virtual Keysyms are meant to provide a consistent keyboard model for Motif
  3403. applications running in a heterogeneous environment in which proprietary (i.e.
  3404. vendor specific) non-Motif applications may also be running.
  3405.  
  3406. First of all, for the sake of the rest of the readers, let's explain why this
  3407. is an issue:
  3408.  
  3409. It would be lovely if Motif's translation tables could just use the obvious
  3410. keysyms predefined by X.  For example, there are keysyms for XK_BackSpace,
  3411. XK_Delete, XK_Left, XK_Right, etc.  Shouldn't these be the ones that are used
  3412. in our translations?  Unfortunately, the problem is not so simple.  Some
  3413. specific examples:
  3414.  
  3415.    While most vendors bind XK_BackSpace to the key at the top right
  3416.    of the standard keyboard (often engraved with a leftwards
  3417.    pointing arrow), not all do.  In fact, some vendors (including DEC)
  3418.    bind that key to XK_Delete.
  3419.  
  3420.    While most vendors bind the arrow keys to XK_Up, etc, a number of
  3421.    vendors (including Sun, on some servers) bind them to function key
  3422.    keysyms.
  3423.  
  3424. A simplistic solution would require the use of xmodmap to change the offending
  3425. bindings.  That would work swell in an all Motif environment.  However, OSF's
  3426. goal (not always perfectly achieved) is interoperability.  That is, we'd like
  3427. to make sure that both Motif and non-Motif programs can happily run in the
  3428. same environment.
  3429.  
  3430. It is expected that a vendor may have a wide variety of existing X-based
  3431. software that uses the keysyms as established by that vendor for specific
  3432. purposes.  It is expected that these applications may run at the same time as
  3433. Motif-based software.  Using xmodmap to change keysyms on the server side
  3434. could "break" the existing applications (or at the very least their
  3435. documentation) by making some keys unavailable, or by moving the location.
  3436.  
  3437. So, we chose not to use xmodmap.  By the way, though OpenLook uses a different
  3438. implementation (they recompile their virtual translation tables into actual
  3439. translation tables), they basically adopted the same approach, presumably for
  3440. similar reasons.
  3441.  
  3442. To work properly, the virtual keysym model we implemented depends on Xlib
  3443. finding XKeysymDB installed appropriately (which standard Motif installation
  3444. does).  This simply defines the keysyms (not the key they are bound to).  This
  3445. unfortunate piece of stupidity is necessary because MIT only includes standard
  3446. keysyms in keysymdef.h.  It should be said that our lives would be made easier
  3447. if MIT would also see fit to include registered keysyms in keysymdef.h as
  3448. well.
  3449.  
  3450. Motif applications determine how to bind virtual to actual keys by looking for
  3451. either a resource or a property on the root window which describes what to do.
  3452. Note that this information is on the server side, so that all applications use
  3453. the same virtual bindings regardless of where they are running.  Mwm will
  3454. happily create the property if it finds a .motifbind file in your home
  3455. directory when it starts up.  (Actually, things generally work even if none of
  3456. this is done, since if all else fails, the Motif toolkit chooses a virtual
  3457. bindings table to use based on the identification of the server).
  3458.  
  3459. The actual implementation of virtual keys is made possible by a hook in the
  3460. Intrinsics.  Undoubtably, the implementation would be simpler and cleaner if
  3461. virtual key support was more directly supported by the Intrinsics.  We will be
  3462. exploring this possibility in the future.
  3463.  
  3464.   -- Ellis
  3465.  
  3466. -----------------------------------------------------------------------------
  3467. END OF PART FOUR
  3468.  
  3469. -----------------------------------------------------------------------------
  3470. Subject: 115) TOPIC: ICONS
  3471.  
  3472. Iconification/de-iconification is a co-operative process between a client and
  3473. a window manager.  The relevant standards are set by ICCCM.  Mwm is ICCCM
  3474. compliant.  The toplevel (non-override-redirect) windows of an application may
  3475. be in three states: WithdrawnState (neither the window nor icon visible),
  3476. NormalState (the window visible) or IconicState (the icon window or pixmap
  3477. visible).  This information is contained in the WM_STATE property but ordinary
  3478. clients are not supposed to look at that (its values have not yet been
  3479. standardised).  Movement between the three states is standardised by ICCCM.
  3480.  
  3481. -----------------------------------------------------------------------------
  3482. Subject: 116) How can I keep track of changes to iconic/normal window state?
  3483.  
  3484. Answer: You can look at the WM_STATE property, but this breaks ICCCM
  3485. guidelines.  ICCCM compliant window managers will map windows in changing them
  3486. to normal state and unmap them in changing them to iconic state. Look for
  3487. StructureNotify events and check the event type:
  3488.  
  3489.         XtAddEventHandler (toplevel_widget,
  3490.                         StructureNotifyMask,
  3491.                         False,
  3492.                         StateWatcher,
  3493.                         (Opaque) NULL);
  3494.         ....
  3495.         void StateWatcher (w, unused, event)
  3496.         Widget w;
  3497.         caddr_t unused;
  3498.         XEvent *event;
  3499.         {
  3500.                 if (event->type == MapNotify)
  3501.                         printf ("normal\n");
  3502.                 else if (event->type == UnmapNotify)
  3503.                         printf ("iconified\n");
  3504.                 else    printf ("other event\n");
  3505.         }
  3506.  
  3507.  
  3508. If you insist on looking at WM_STATE, here is some code (from Ken Sall) to do
  3509. it:
  3510.  
  3511.         /*
  3512.         ------------------------------------------------------------------
  3513.         Try a function such as CheckWinMgrState below which returns one of
  3514.         IconicState | NormalState | WithdrawnState | NULL :
  3515.         ------------------------------------------------------------------
  3516.         */
  3517.         #define WM_STATE_ELEMENTS 1
  3518.  
  3519.         unsigned long *CheckWinMgrState (dpy, window)
  3520.         Display *dpy;
  3521.         Window window;
  3522.         {
  3523.           unsigned long *property = NULL;
  3524.           unsigned long nitems;
  3525.           unsigned long leftover;
  3526.           Atom xa_WM_STATE, actual_type;
  3527.           int actual_format;
  3528.           int status;
  3529.  
  3530.             xa_WM_STATE = XInternAtom (dpy, "WM_STATE", False);
  3531.  
  3532.             status = XGetWindowProperty (dpy, window,
  3533.                           xa_WM_STATE, 0L, WM_STATE_ELEMENTS,
  3534.                           False, xa_WM_STATE, &actual_type, &actual_format,
  3535.                           &nitems, &leftover, (unsigned char **)&property);
  3536.  
  3537.             if ( ! ((status == Success) &&
  3538.                         (actual_type == xa_WM_STATE) &&
  3539.                         (nitems == WM_STATE_ELEMENTS)))
  3540.                 {
  3541.                 if (property)
  3542.                     {
  3543.                     XFree ((char *)property);
  3544.                     property = NULL;
  3545.                     }
  3546.                 }
  3547.             return (property);
  3548.         } /* end CheckWinMgrState */
  3549.  
  3550.  
  3551. -----------------------------------------------------------------------------
  3552. Subject: 117) How can I check if my application has come up iconic?  I want to
  3553. delay initialisation code and other processing.
  3554.  
  3555. Answer: Use XtGetValues and check for the XmNinitialState value of the
  3556. toplevel shell just before XtMainLoop. -- IconicState is iconic, NormalState
  3557. is not iconic.
  3558.  
  3559.  
  3560.  
  3561.  
  3562. -----------------------------------------------------------------------------
  3563. Subject: 118) How can I start my application in iconic state?
  3564.  
  3565. Answer: From the command line
  3566.  
  3567.         application -iconic
  3568.  
  3569. Using the resource mechanism, set the resource XmNinitialState to IconicState
  3570. of the toplevel shell widget (the one returned from XtInitialise).
  3571.  
  3572. -----------------------------------------------------------------------------
  3573. Subject: 119) How can an application iconify itself?
  3574.  
  3575. Answer: In R4 and later, use the call XIconifyWindow.
  3576.  
  3577. For R3, send an event to the root window with a type of WM_CHANGE_STATE and
  3578. data IconicState.
  3579.  
  3580.         void
  3581.         IconifyMe (dpy, win)
  3582.         Display *dpy;
  3583.         Window win;     /* toplevel window to iconify */
  3584.         {
  3585.                 Atom xa_WM_CHANGE_STATE;
  3586.                 XClientMessageEvent ev;
  3587.  
  3588.                 xa_WM_CHANGE_STATE = XInternAtom (dpy,
  3589.                                         "WM_CHANGE_STATE", False);
  3590.  
  3591.                 ev.type = ClientMessage;
  3592.                 ev.display = dpy;
  3593.                 ev.message_type = xa_WM_CHANGE_STATE;
  3594.                 ev.format = 32;
  3595.                 ev.data.l[0] = IconicState;
  3596.                 ev.window = win;
  3597.  
  3598.                 XSendEvent (dpy,
  3599.                         RootWindow (dpy, DefaultScreen(dpy)),
  3600.                         True,
  3601.                         (SubstructureRedirectMask | SubstructureNotifyMask),
  3602.                         &ev);
  3603.                 XFlush (dpy);
  3604.         }
  3605.  
  3606.  
  3607. -----------------------------------------------------------------------------
  3608. Subject: 120) How can an application de-iconify itself?
  3609.  
  3610. Answer: XMapWindow (XtDisplay (toplevel_widget), XtWindow (toplevel_widget)).
  3611.  
  3612. -----------------------------------------------------------------------------
  3613. Subject: 121) TOPIC: MISCELLANEOUS
  3614.  
  3615. -----------------------------------------------------------------------------
  3616. Subject: 122)+ What is the matter with Frame in Motif 1.2?
  3617.  
  3618. [Last modified: November 92]
  3619.  
  3620. Answer: This announcement has been made by OSF:
  3621.  
  3622. "IMPORTANT NOTICE
  3623.  
  3624. We have discovered two problems in the new 1.2 child alignment resources in
  3625. XmFrame. Because some vendors may have committed, or are soon to commit to
  3626. field releases of Motif 1.2 and 1.2.1, OSF's options for fixing them are
  3627. limited. We are trying to deal with these in a way that does not cause
  3628. hardship for application developers who will develop applications against
  3629. various point versions of Motif. OSF's future actions for correction are
  3630. summarized.
  3631.  
  3632. WHAT YOU SHOULD DO AND KNOW
  3633.  
  3634. 1. Mark the following change in your documentation.
  3635.  
  3636. On page 1-512 of the OSF/Motif Programmer's Reference, change the descriptions
  3637. under XmNchildVerticalAlignment as follows (what follows is the CORRECT
  3638. wording to match the current implementation):
  3639.  
  3640. XmALIGNMENT_WIDGET_TOP
  3641.         Causes the BOTTOM edge of the title area to align
  3642.         vertically with the top shadow of the Frame.
  3643.  
  3644. XmALIGNMENT_WIDGET_BOTTOM
  3645.         Causes the TOP edge of the title area to align
  3646.         vertically with the top shadow of the Frame.
  3647.  
  3648. 2. Note the following limitation on resource converters for Motif 1.2 and
  3649. 1.2.1 implementations.
  3650.  
  3651. The rep types for XmFrame's XmNentryVerticalAlignment resource were
  3652. incorrected implemented, which means that converters will not work properly.
  3653. The following resource settings will not work from a resource file in 1.2 and
  3654. 1.2.1:
  3655.  
  3656.         *childVerticalAlignment: alignment_baseline_bottom
  3657.         *childVerticalAlignment: alignment_baseline_top
  3658.         *childVerticalAlignment: alignment_widget_bottom
  3659.         *childVerticalAlignment: alignment_widget_top
  3660.  
  3661. If you wish to set these values for these resources (note they are new
  3662. constraint resources in XmFrame) you will have to set them directly in C or
  3663. via uil.
  3664.  
  3665. WHAT WE WILL DO
  3666.  
  3667. The problem described in note #1 above will not be fixed in the OSF/Motif
  3668. implementation until the next MAJOR release of Motif.  At that time we will
  3669. correct the documentation and modify the code to match those new descriptions,
  3670. but we will preserve the existing enumerated values and their behavior for
  3671. backward compatibility for that release.
  3672.  
  3673. The fix for the problem described in note #2 will be shipped by OSF in Motif
  3674. 1.2.2.
  3675.  
  3676. SUMMARY
  3677. We are sorry for any difficulty this causes Motif users.  If you have any
  3678. questions or flames (I suppose I deserve it) please send them directly to me.
  3679. We sincerely hope this proactive response is better for our customers than you
  3680. having to figure it out yourselves!
  3681.  
  3682. Libby
  3683.  
  3684.  
  3685. -----------------------------------------------------------------------------
  3686. Subject: 123)  What is IMUG and how do I join it?
  3687.  
  3688. Answer: IMUG is the International Motif User Group founded by Quest Windows
  3689. Corporation and co-sponsored by FedUNIX.  IMUG is a non-profit organization
  3690. working to keep users informed on technical and standards issues, to
  3691. strengthen user groups on a local level, to increase communication among users
  3692. internationally, and to promote the use of an international conference as a
  3693. forum for sharing and learning more about Motif.  You can join it by
  3694.  
  3695.  1.  Pay the annual membership fee of $20 USD directly to IMUG.  Contact
  3696.  
  3697.      IMUG
  3698.      5200 Great America Parkway
  3699.      Santa Clara,  CA  95054
  3700.      (408) 496-1900
  3701.      imug@quest.com
  3702.  
  3703.  2.  Register at the International Motif User Conference, and automatically
  3704.      become an IMUG member.
  3705.  
  3706.  3.  Donate a pd widget, widget tool or widget builder to the IMUG Widget
  3707.      Depository and receive a free one year IMUG membership.
  3708.  
  3709.  
  3710.  
  3711. -----------------------------------------------------------------------------
  3712. Subject: 124)  How do I set the title of a top level window?
  3713. [Last modified: September 92]
  3714.  
  3715. Answer: Set XmNtitle (and optionally XmNtitleEncoding) for TopLevelShells.
  3716. (Note that this is of type String rather than XmStrin.) Ypu can also set
  3717. XmNiconName if you want its icon to show this title.  For XmDialogShells, set
  3718. the XmNdialogTitle of its immediate child, assuming it's a BulletinBoard
  3719. subclass.  These can also be set in resource files.
  3720.  
  3721.  
  3722. -----------------------------------------------------------------------------
  3723. Subject: 125)  Can I use editres with Motif?
  3724. [Last modified: August 92]
  3725.  
  3726. Answer: It isn't built in to Motif (at 1.2.0), but you can do this in your
  3727. application
  3728.  
  3729.     extern void _XEditResCheckMessages();
  3730.     ...
  3731.     XtAddEventHandler(shell_widget, (EventMask)0, True,
  3732.                         _XEditResCheckMessages, NULL);
  3733.  
  3734. once for each shell widget that you want to react to the "click to select
  3735. client" protocol.  Then link your client with the R5 libXmu.
  3736.  
  3737. David Brooks, OSF
  3738.  
  3739.  
  3740. -----------------------------------------------------------------------------
  3741. Subject: 126)  How can I put decorations on transient windows using olwm?
  3742.  
  3743. Answer: From Jean-Philippe Martin-Flatin <syj@ecmwf.co.uk>
  3744.  
  3745. /**********************************************************************
  3746. ** WindowDecorations.c
  3747. **
  3748. ** Manages window decorations under the OpenLook window manager (OLWM).
  3749. **
  3750. ** Adapted from a C++ program posted to comp.windows.x.motif by:
  3751. **
  3752. **    +--------------------------------------------------------------+
  3753. **    | Ron Edmark                          User Interface Group     |
  3754. **    | Tel:        (408) 980-1500 x282     Integrated Systems, Inc. |
  3755. **    | Internet:   edmark@isi.com          3260 Jay St.             |
  3756. **    | Voice mail: (408) 980-1590 x282     Santa Clara, CA 95054    |
  3757. **    +--------------------------------------------------------------+
  3758. ***********************************************************************/
  3759.  
  3760. #include <X11/X.h>
  3761. #include <X11/Xlib.h>
  3762. #include <X11/Xatom.h>
  3763. #include <X11/Intrinsic.h>
  3764. #include <X11/StringDefs.h>
  3765. #include <X11/Protocols.h>
  3766. #include <Xm/Xm.h>
  3767. #include <Xm/AtomMgr.h>
  3768.  
  3769. /*
  3770. ** Decorations for OpenLook:
  3771. ** The caller can OR different mask options to change the frame decoration.
  3772. */
  3773. #define OLWM_Header     (long)(1<<0)
  3774. #define OLWM_Resize     (long)(1<<1)
  3775. #define OLWM_Close      (long)(1<<2)
  3776.  
  3777. /*
  3778. ** Prototypes
  3779. */
  3780. static void InstallOLWMAtoms  (Widget w);
  3781. static void AddOLWMDialogFrame(Widget widget, long decorationMask);
  3782.  
  3783.  
  3784. /*
  3785. ** Global variables
  3786. */
  3787. static Atom AtomWinAttr;
  3788. static Atom AtomWTOther;
  3789. static Atom AtomDecor;
  3790. static Atom AtomResize;
  3791. static Atom AtomHeader;
  3792. static Atom AtomClose;
  3793. static int  not_installed_yet = TRUE;
  3794.  
  3795.  
  3796. static void InstallOLWMAtoms(Widget w)
  3797. {
  3798.         AtomWinAttr = XInternAtom(XtDisplay(w), "_OL_WIN_ATTR" ,    FALSE);
  3799.         AtomWTOther = XInternAtom(XtDisplay(w), "_OL_WT_OTHER",     FALSE);
  3800.         AtomDecor   = XInternAtom(XtDisplay(w), "_OL_DECOR_ADD",    FALSE);
  3801.         AtomResize  = XInternAtom(XtDisplay(w), "_OL_DECOR_RESIZE", FALSE);
  3802.         AtomHeader  = XInternAtom(XtDisplay(w), "_OL_DECOR_HEADER", FALSE);
  3803.         AtomClose   = XInternAtom(XtDisplay(w), "_OL_DECOR_CLOSE",  FALSE);
  3804.  
  3805.         not_installed_yet = FALSE;
  3806. }
  3807.  
  3808. static void AddOLWMDialogFrame(Widget widget, long decorationMask)
  3809. {
  3810.         Atom   winAttrs[2];
  3811.         Atom   winDecor[3];
  3812.         Widget shell = widget;
  3813.         Window win;
  3814.         int    numberOfDecorations = 0;
  3815.  
  3816.         /*
  3817.         ** Make sure atoms for OpenLook are installed only once
  3818.         */
  3819.         if (not_installed_yet) InstallOLWMAtoms(widget);
  3820.  
  3821.         while (!XtIsShell(shell)) shell = XtParent(shell);
  3822.  
  3823.         win = XtWindow(shell);
  3824.  
  3825.         /*
  3826.         ** Tell Open Look that our window is not one of the standard OLWM window        ** types. See OLIT Widget Set Programmer's Guide pp.70-73.
  3827.         */
  3828.  
  3829.         winAttrs[0] = AtomWTOther;
  3830.  
  3831.         XChangeProperty(XtDisplay(shell),
  3832.                         win,
  3833.                         AtomWinAttr,
  3834.                         XA_ATOM,
  3835.                         32,
  3836.                         PropModeReplace,
  3837.                         (unsigned char*)winAttrs,
  3838.                         1);
  3839.  
  3840.         /*
  3841.         ** Tell Open Look to add some decorations to our window
  3842.         */
  3843.         numberOfDecorations = 0;
  3844.         if (decorationMask & OLWM_Header)
  3845.                 winDecor[numberOfDecorations++] = AtomHeader;
  3846.         if (decorationMask & OLWM_Resize)
  3847.                 winDecor[numberOfDecorations++] = AtomResize;
  3848.         if (decorationMask & OLWM_Close)
  3849.         {
  3850.                 winDecor[numberOfDecorations++] = AtomClose;
  3851.  
  3852.                 /*
  3853.                 ** If the close button is specified, the header must be
  3854.                 ** specified. If the header bit is not set, set it.
  3855.                 */
  3856.                 if (!(decorationMask & OLWM_Header))
  3857.                         winDecor[numberOfDecorations++] = AtomHeader;
  3858.         }
  3859.  
  3860.         XChangeProperty(XtDisplay(shell),
  3861.                         win,
  3862.                         AtomDecor,
  3863.                         XA_ATOM,
  3864.                         32,
  3865.                         PropModeReplace,
  3866.                         (unsigned char*)winDecor,
  3867.                         numberOfDecorations);
  3868. }
  3869.  
  3870.  
  3871. /*
  3872. ** Example of use of AddOLWMDialogFrame, with a bit of extra stuff
  3873. */
  3874. void register_dialog_to_WM(Widget shell, XtCallbackProc Cbk_func)
  3875. {
  3876.         Atom atom;
  3877.  
  3878.         /*
  3879.         ** Alias the "Close" item in system menu attached to dialog shell
  3880.         ** to the activate callback of "Exit" in the menubar
  3881.         */
  3882.         if (Cbk_func)
  3883.         {
  3884.             atom = XmInternAtom(XtDisplay(shell),"WM_DELETE_WINDOW",TRUE);
  3885.             XmAddWMProtocolCallback(shell,atom, Cbk_func,NULL);
  3886.         }
  3887.  
  3888.         /*
  3889.         ** If Motif is the window manager, skip OpenLook specific stuff
  3890.         */
  3891.         if (XmIsMotifWMRunning(shell)) return;
  3892.  
  3893.         /*
  3894.         ** Register dialog shell to OpenLook.
  3895.         **
  3896.         ** WARNING: on some systems, adding the "Close" button allows the title
  3897.         ** to be properly centered in the title bar. On others, activating
  3898.         ** "Close" crashes OpenLook. The reason is not clear yet, but it seems
  3899.         ** the first case occurs with OpenWindows 2 while the second occurs with
  3900.         ** Openwindows 3. Thus, comment out one of the two following lines as
  3901.         ** suitable for your site, and send e-mail to syj@ecmwf.co.uk if you
  3902.         ** find out what is going on !
  3903.         */
  3904.         AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize));
  3905. /*      AddOLWMDialogFrame(shell,(OLWM_Header | OLWM_Resize | OLWM_Close)); */
  3906. }
  3907.  
  3908.  
  3909. -----------------------------------------------------------------------------
  3910. Subject: 127) Why does an augment translation appear to act as replace for
  3911. some widgets?  When I use either augment or override translations in
  3912. .Xdefaults it seems to act as replace in both Motif 1.0 and 1.1
  3913.  
  3914. Answer: By default, the translation table is NULL.  If there is nothing
  3915. specified (either in resource file, or in args), the widget's Initialize
  3916. finds: Oh, there is NULL in translations, lets use our default ones.  If,
  3917. however, the translations have become non-NULL, the default translations are
  3918. NOT used at all. Thus, using #augment, #override or a new table has identical
  3919. effect: defines the new translations. The only way you can augment/override
  3920. Motif's default translations is AFTER Initialize, using XtSetValues.  Note,
  3921. however, that Motif managers do play with translation tables as well ... so
  3922. that results are not always easy to predict.
  3923.  
  3924. From OSF: A number of people have complained about not being able to
  3925. augment/override translations from the .Xdefaults.  This is due to the
  3926. complexity of the menu system/keyboard traversal and the necessary
  3927. translations changes required to support the Motif Style Guide in menus.  It
  3928. cannot be fixed in a simple way. Fixing it requires re-design of the
  3929. menus/buttons and it is planned to be fixed in 1.2.
  3930.  
  3931.  
  3932.  
  3933.  
  3934.  
  3935. -----------------------------------------------------------------------------
  3936. Subject: 128) How do you "grey" out a widget so that it cannot be activated?
  3937.  
  3938. Answer: Use XtSetSensitive(widget, False). Do not set the XmNsensitive
  3939. resource directly yourself (by XtSetValues) since the widget may need to talk
  3940. to parents first.
  3941.  
  3942.  
  3943. -----------------------------------------------------------------------------
  3944. Subject: 129) Why doesn't the Help callback work on some widgets?
  3945.  
  3946. Answer: If you press the help key the help callback of the widget with the
  3947. keyboard focus is called (not the one containing the mouse).  You can't get
  3948. the help callback of a non-keyboard-selectable widget called. To get `context
  3949. sensitive' help on these, you have to find the mouse, associate its position
  3950. with a widget and then do the help.
  3951.  
  3952.  
  3953.  
  3954. -----------------------------------------------------------------------------
  3955. Subject: 130) Where can I get a Table widget?
  3956.  
  3957. Answer: Send email to Kee Hinckley (nazgul@alfalfa.com) asking for a copy of
  3958. his table widget.  The Widget Creation Library also has one.  See under Motif
  3959. prototyping tools for the contact.
  3960.  
  3961. Expert Database Systems, Inc., 305 Madison Ave, Suite 1166, New York, NY 10165
  3962. has a very comprehensive table widget that uses both motif scrollbars or a
  3963. "virtual" scrollbar showing a miniature version of the entire spreadsheet.
  3964. Allows for different width columns, changing colors in each cell.  Only one
  3965. X-Window is used so as to reduce the amount of system resources used.  Contact
  3966. Ken Jones
  3967.  
  3968.  
  3969. -----------------------------------------------------------------------------
  3970. Subject: 131)  Has anyone done a bar graph widget?
  3971. [Last modified: September 92]
  3972.  
  3973. Answer: You can fake one by using for each bar a scroll bar or even a label
  3974. which changes in size, put inside a container of some kind.
  3975.  
  3976. Try the StripChart widget in the Athena widget set. Set the XtNupdate resource
  3977. to 0 to keep it from automatically updating.
  3978.  
  3979. The comp.windows.x FAQ mentions a bar graph widget.
  3980.  
  3981. Expert Database Systems, Inc.  sells a bar graph widget as well as a multi-
  3982. line graph with automatic scaling, a 3-D surface graph, and a high/Low graph
  3983. with two lines for moving averages.  Contact Ken Jones Expert Database
  3984. Systems, Inc., 305 Madison Ave, Suite 1166, New York, NY 10165, Main Number:
  3985. (212) 370-6700, Phone Mail:  (212) 714-8345
  3986.  
  3987. The Xtra XWidget library contains a set of widgets that are subclassed from
  3988. and compatible with either OSF/Motif or OLIT widgets.  The library includes
  3989. widgets that implement the following:
  3990.  
  3991.    Spreadsheet
  3992.    Bar Graph
  3993.    Stacked Bar Graph
  3994.    Line Graph
  3995.    Pie Chart
  3996.    XY Plot
  3997.    Hypertext
  3998.    Hypertext based Help System
  3999.    Entry Form with type checking
  4000.  
  4001. Contact Graphical Software Technology at 310-328-9338  (info@gst.com) for
  4002. information.
  4003.  
  4004. The XRT/graph widget, available for Motif, XView and OLIT, displays X-Y plots,
  4005. bar and pie charts, and supports user-feedback, fast updates and PostScript
  4006. output. Contact KL Group Inc. at 416-594-1026 (xrt_info%klg@uunet.ca)
  4007.  
  4008. The product Xmath, made by Integrated Systems Inc. is a product which has
  4009. interactive 2d and 3d graphics for bar,strip,line,symbol,
  4010. surface,contour,etc... that costs $2500.00 for commercial use and a mere
  4011. $250.00 for university use that also has complete numerics capabilities, an
  4012. easy to use debugger, a complete high level language, a spreadsheet, a motif
  4013. gui access capability, and much more all created on top of motif.
  4014.  
  4015. You can either email to xmath-info@isi.com or call (408)980-1500.
  4016.  
  4017. Digital Equipment Corporation (DEC) provides the following product NetEd: "The
  4018. network editor widget is a Motif toolkit conforming widget that applications
  4019. can use to express complex interrelationships graphically in the form of
  4020. networks or graphs. The network editor supports interactive or application-
  4021. controlled creation and editing of directed graphs or networks."
  4022.  
  4023.  
  4024. ACE/gr is an X based XY plotting tool implemented with a point 'n click
  4025. paradigm.  A few of its features are:
  4026.  
  4027.    * Plots up to 10 graphs with 30 data sets per graph.
  4028.    * Data read from files and/or pipes.
  4029.    * Graph types XY, log-linear, linear-log, log-log, bar,
  4030.         stacked bar charts.
  4031.  
  4032. it is available from
  4033.  
  4034.         ftp.ccalmr.ogi.edu (presently amb4.ccalmr.ogi.edu)
  4035.  
  4036. with IP address 129.95.72.34. The XView version (xvgr) will be found in
  4037. /CCALMR/pub/acegr/xvgr-2.09.tar.Z and the Motif version (xmgr) in
  4038. /CCALMR/pub/acegr/xmgr-2.09.tar.Z.  Comments, suggestions, bug reports to
  4039. pturner@amb4.ccalmr.ogi.edu (if mail fails, try pturner@ese.ogi.edu). Due to
  4040. time constraints, replies will be few and far between.
  4041.  
  4042.  
  4043.  
  4044. -----------------------------------------------------------------------------
  4045. Subject: 132)  Does anyone know of a source code of a graph widget where you
  4046. can add vertices and edges and get an automated updating?
  4047.  
  4048. [Last modified: September 92]
  4049.  
  4050. Answer: The XUG FAQ in comp.windows.x includes information on graph display
  4051. widgets.  There is also an implementation in the Asente/Swick book.
  4052.  
  4053.   From Martin Janzen: "You could have a look at DataViews, from V.I.
  4054.    Corporation.  This package is used mainly to display a variety of graph
  4055.    drawings (eg. bar, line, pie, high/low, and other charts), and to update
  4056.    the graphs as information is received from "data sources" such as files,
  4057.    processes (through pipes), or devices.
  4058.  
  4059.    However, it also provides "node" and "edge" objects which can be used
  4060.    when working with network graphs.  The DV-Tools function library
  4061.    provides routines which traverse a graph, count visits to each node or
  4062.    edge, mark nodes or edges of interest, and so on.  A node or edge object
  4063.    can have an associated "geometry object" (such as a symbol or a line),
  4064.    which represents that node or edge.
  4065.  
  4066.    Drawbacks: There's no automatic positioning algorithm; when you add a
  4067.    node or edge, you have to create and position its geometry object
  4068.    yourself.  Also, this isn't a set of add-on widgets; you can either have
  4069.    DataViews create an X window (ie. a separate shell), or you can create
  4070.    your own XmDrawingArea and use DataViews to update its window when
  4071.    expose events are received.  Finally, the package is quite expensive,
  4072.    and there is a run-time charge.
  4073.  
  4074.    The vendor's address is:
  4075.      V.I. Corporation,
  4076.      47 Pleasant Street,
  4077.      Northampton, MA  01060,
  4078.             Email: vi@vicorp.com, Phone: (413) 586-4144, Fax:   (413) 584-2649
  4079.  
  4080.    or
  4081.  
  4082.      V.I. Corporation (Europe) Ltd.,
  4083.      First Base, Beacontree Plaza,
  4084.      Gillette Way,                      Email: viesales@eurovi.uucp
  4085.      Reading, Berkshire  RG2 0BP"
  4086.    Phone: +44 734 756010,      Fax:   +44 734 756104
  4087.  
  4088. From Craig Timmerman: Just wanted others to know that there is a third
  4089. competitor in what may be come a big market for generic APIs.  The product is
  4090. called Open Interface and Neuron Data is the vendor.  Neuron has added some
  4091. extra, more complex widgets to their set.  The two most notable are a table
  4092. and network widget.  [...] I believe that the network widget got its name from
  4093. its ability to display expert system networks that Neuron's AI tools needed.
  4094. It would be more aptly named the graph widget.  It can display and manipulate
  4095. graphs of various types (trees, directed graphs, etc).  Contact is
  4096.  
  4097.         Neuron Data
  4098.         156 University Avenue
  4099.         Palo Alto,  CA  94301
  4100.         (415) 321-4488
  4101.  
  4102.  
  4103. prism!gt3273b@gatech.edu  (RENALDS,ANDREW THEODORE) posted a set of public
  4104. domain routines for graph drawing.  Contact him for a later set.
  4105.  
  4106. From Ramon Santiago (santiago@fgssu1.fgs.slb.com): HP has released source code
  4107. for XmGraph and XmArc, part of the InterWorks library, which does exactly
  4108. this. The sources can be obtained by contacting Dave Shaw,
  4109. librarian@iworks.ecn.uiowa.edu. A few trivial source code changes need to be
  4110. made to get these widgets to compile under Motif 1.2.
  4111.  
  4112.  
  4113. -----------------------------------------------------------------------------
  4114. Subject: 133)  Is there a help system available, such as in Windows 3?  Or any
  4115. Motif based hypertext system.
  4116.  
  4117. Answer:
  4118.  
  4119. Bristol Technology have a hypertext system HyperHelp with the look-and-feel of
  4120. either Motif or OpenLook. It should be available from january 31, 1992.
  4121. Contact
  4122.  
  4123.         Bristol Technology Inc.
  4124.         898 Ethan Allen Highway
  4125.         Ridgefield, CT  06877
  4126.         203-438-6969 (phone)
  4127.         203-438-5013 (fax)
  4128.         uunet.uu.net!bristol!keith
  4129.  
  4130. Demos are available by anonymous ftp from  ftp.uu.net (137.39.1.9) in the
  4131. vendor/Bristol/HyperHelp as files sun.motif.tar.Z and hp.tar.Z.
  4132.  
  4133. There was a posting of a motif hypertext-widget to comp.sources.x (Author:
  4134. B.Raoult ( mab@ecmwf.co.uk ) ).  It had the facility to read in helptext from
  4135. a file.
  4136.  
  4137. From Francois Felix Ingrand (felix@idefix.laas.fr): I have translated the Info
  4138. AW (originally written by Jordan Hubbard) to Motif. It is a Widget to browse
  4139. Info files (format used by GNU for their various documentations). I use it as
  4140. the help system of various tool I wrote.  It is available on laas.laas.fr
  4141. (140.93.0.15) in /pub/prs/xinfo-motif.tar.Z
  4142.  
  4143. Form Scott Raney (raney@metacard.com) MetaCard is a commercial package that
  4144. can be used to implement hypertext help.  The text fields support multiple
  4145. typefaces, sizes, styles, colors, subscript/superscript, and hypertext links.
  4146. It has a Motif interface, and a template for calling it from an Xt/Motif
  4147. application is included.  You can FTP a save-disabled distribution from
  4148. ftp.metacard.com or from world.std.com.  For more info, email to
  4149. info@metacard.com.
  4150.  
  4151.  
  4152.  
  4153.  
  4154. -----------------------------------------------------------------------------
  4155. Subject: 134) Can I specify a widget in a resource file?
  4156.  
  4157. Answer: This answer, which uses the Xmu library, is due to David Elliott.  If
  4158. the converter is added, then the name of a widget (a string) can be used in
  4159. resource files, and will be converted to the appropriate widget.
  4160.  
  4161. This code, which was basically stolen from the Athena Form widget, adds a
  4162. String to Widget converter.  I wrote it as a general routine that I call at
  4163. the beginning of all of my programs, and made it so I could add other
  4164. converters as needed (like String to Unit Type ;-).
  4165.  
  4166.         #include <X11/Intrinsic.h>
  4167.         #include <X11/StringDefs.h>
  4168.         #include <Xm/Xm.h>
  4169.         #include <X11/Xmu/Converters.h>
  4170.         #include <X11/IntrinsicP.h>
  4171.         #include <X11/CoreP.h>
  4172.  
  4173.         void
  4174.         setupConverters()
  4175.         {
  4176.                 static XtConvertArgRec parentCvtArgs[] = {
  4177.                         {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent),
  4178.                                 sizeof(Widget)}
  4179.                 };
  4180.  
  4181.                 XtAddConverter(XmRString, XmRWindow, XmuCvtStringToWidget,
  4182.                         parentCvtArgs, XtNumber(parentCvtArgs));
  4183.         }
  4184.  
  4185.  
  4186.  
  4187. -----------------------------------------------------------------------------
  4188. Subject: 135) Why are only some of my translations are being installed?  I
  4189. have a translation table like the following, but only the first ones are
  4190. getting installed and the rest are ignored.
  4191.  
  4192.  *Text.translations:    #override \
  4193.      Ctrl<Key>a:    beginning-of-line() \n\
  4194.      Ctrl<Key>e:    end-of-line() \n\
  4195.      Ctrl<Key>f:    forward-character() \n\
  4196.  
  4197.  
  4198. Answer: Most likely, you have a space at the end of one of the lines (the
  4199. first in this case).
  4200.  
  4201.      Ctrl<Key>a:    beginning-of-line() \n\
  4202.                                            ^ space here
  4203.  
  4204. The second backslash in each line is there to protect the real newline
  4205. character and so you must not follow it with anything other than the newline
  4206. itself. Otherwise it acts as the end of the resource definition and the
  4207. remaining lines are not added.
  4208.  
  4209.  
  4210. -----------------------------------------------------------------------------
  4211. Subject: 136)  Where can I get the PanHandler code?
  4212.  
  4213. Answer: It is available by email from Chuck Ocheret:  chuck@IMSI.COM.
  4214.  
  4215. -----------------------------------------------------------------------------
  4216. Subject: 137) What are these passive grab warnings?  When I destroy certain
  4217. widgets I get a stream of messages
  4218.  
  4219.     Warning: Attempt to remove non-existant passive grab
  4220.  
  4221.  
  4222. Answer: They are meaningless, and you want to ignore them.  Do this (from Kee
  4223. Hinckley) by installing an XtWarning handler that explicitly looks for them
  4224. and discards them:
  4225.  
  4226.         static void xtWarnCB(String message) {
  4227.            if (asi_strstr(message, "non-existant passive grab", TRUE)) return;
  4228.            ...
  4229.  
  4230. They come from Xt, and (W. Scott Meeks): "it's something that the designers of
  4231. Xt decided the toolkit should do. Unfortunately, Motif winds up putting
  4232. passive grabs all over the place for the menu system.  On the one hand, we
  4233. want to remove all these grabs when menus get destroyed so that they don't
  4234. leak memory; on the other hand, it's almost impossible to keep track of all
  4235. the grabs, so we have a conservative strategy of ungrabbing any place where a
  4236. grab could have been made and we don't explicitly know that there is no grab.
  4237. The unfortunate side effect is the little passive grab warning messages.
  4238. We're trying to clean these up where possible, but there are some new places
  4239. where the warning is generated.  Until we get this completely cleaned up (1.2
  4240. maybe), your best bet is probably to use a warning handler."
  4241.  
  4242. -----------------------------------------------------------------------------
  4243. Subject: 138) How do I have more buttons than three in a box?  I want to have
  4244. something like a MessageBox (or other widget) with more than three buttons,
  4245. but with the same nice appearance.
  4246.  
  4247. Answer: A SelectionBox is created with four buttons, but the fourth (the Apply
  4248. button) is unmanaged. To manage it get its widget ID via
  4249. XmSelectionBoxGetChild(parent, XmDIALOG_APPLY_BUTTON) and then XtManage it.
  4250. Unmanage all of the other bits in the SelectionBox that you don't want.  If
  4251. you want more than four buttons, try two SelectionBoxes (or similar) together
  4252. in a container, where all of the unwanted parts of the widgets are unmanaged.
  4253.  
  4254. Alternatively, build your own dialog:
  4255.  
  4256. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  4257.  * This program is freely distributable without licensing fees and
  4258.  * is provided without guarantee or warranty expressed or implied.
  4259.  * This program is -not- in the public domain.  This program is
  4260.  * taken from the Motif Programming Manual, O'Reilly Volume 6.
  4261.  */
  4262.  
  4263. /* action_area.c -- demonstrate how CreateActionArea() can be used
  4264.  * in a real application.  Create what would otherwise be identified
  4265.  * as a PromptDialog, only this is of our own creation.  As such,
  4266.  * we provide a TextField widget for input.  When the user presses
  4267.  * Return, the Ok button is activated.
  4268.  */
  4269. #include <Xm/DialogS.h>
  4270. #include <Xm/PushBG.h>
  4271. #include <Xm/PushB.h>
  4272. #include <Xm/LabelG.h>
  4273. #include <Xm/PanedW.h>
  4274. #include <Xm/Form.h>
  4275. #include <Xm/RowColumn.h>
  4276. #include <Xm/TextF.h>
  4277.  
  4278. typedef struct {
  4279.     char *label;
  4280.     void (*callback)();
  4281.     caddr_t data;
  4282. } ActionAreaItem;
  4283.  
  4284. static void
  4285.     do_dialog(), close_dialog(), activate_cb(),
  4286.     ok_pushed(), cancel_pushed(), help();
  4287.  
  4288. main(argc, argv)
  4289. int argc;
  4290. char *argv[];
  4291. {
  4292.     Widget toplevel, button;
  4293.     XtAppContext app;
  4294.  
  4295.     toplevel = XtVaAppInitialize(&app, "Demos",
  4296.         NULL, 0, &argc, argv, NULL, NULL);
  4297.  
  4298.     button = XtVaCreateManagedWidget("Push Me",
  4299.         xmPushButtonWidgetClass, toplevel, NULL);
  4300.     XtAddCallback(button, XmNactivateCallback, do_dialog, NULL);
  4301.  
  4302.     XtRealizeWidget(toplevel);
  4303.     XtAppMainLoop(app);
  4304. }
  4305.  
  4306. /* callback routine for "Push Me" button.  Actually, this represents
  4307.  * a function that could be invoked by any arbitrary callback.  Here,
  4308.  * we demonstrate how one can build a standard customized dialog box.
  4309.  * The control area is created here and the action area is created in
  4310.  * a separate, generic routine: CreateActionArea().
  4311.  */
  4312. static void
  4313. do_dialog(w, file)
  4314. Widget w; /* will act as dialog's parent */
  4315. char *file;
  4316. {
  4317.     Widget dialog, pane, rc, label, text_w, action_a;
  4318.     XmString string;
  4319.     extern Widget CreateActionArea();
  4320.     Arg args[10];
  4321.     static ActionAreaItem action_items[] = {
  4322.         { "Ok",     ok_pushed,     NULL          },
  4323.         { "Cancel", cancel_pushed, NULL          },
  4324.         { "Close",  close_dialog,  NULL          },
  4325.         { "Help",   help,          "Help Button" },
  4326.     };
  4327.  
  4328.     /* The DialogShell is the Shell for this dialog.  Set it up so
  4329.      * that the "Close" button in the window manager's system menu
  4330.      * destroys the shell (it only unmaps it by default).
  4331.      */
  4332.     dialog = XtVaCreatePopupShell("dialog",
  4333.         xmDialogShellWidgetClass, XtParent(w),
  4334.         XmNtitle,  "Dialog Shell",     /* give arbitrary title in wm */
  4335.         XmNdeleteResponse, XmDESTROY,  /* system menu "Close" action */
  4336.         NULL);
  4337.  
  4338.     /* now that the dialog is created, set the Close button's
  4339.      * client data, so close_dialog() will know what to destroy.
  4340.      */
  4341.     action_items[2].data = (caddr_t)dialog;
  4342.  
  4343.     /* Create the paned window as a child of the dialog.  This will
  4344.      * contain the control area (a Form widget) and the action area
  4345.      * (created by CreateActionArea() using the action_items above).
  4346.      */
  4347.     pane = XtVaCreateWidget("pane", xmPanedWindowWidgetClass, dialog,
  4348.         XmNsashWidth,  1,
  4349.         XmNsashHeight, 1,
  4350.         NULL);
  4351.  
  4352.     /* create the control area (Form) which contains a
  4353.      * Label gadget and a List widget.
  4354.      */
  4355.     rc = XtVaCreateWidget("control_area", xmRowColumnWidgetClass, pane, NULL);
  4356.     string = XmStringCreateSimple("Type Something:");
  4357.     XtVaCreateManagedWidget("label", xmLabelGadgetClass, rc,
  4358.         XmNlabelString,    string,
  4359.         XmNleftAttachment, XmATTACH_FORM,
  4360.         XmNtopAttachment,  XmATTACH_FORM,
  4361.         NULL);
  4362.     XmStringFree(string);
  4363.  
  4364.     text_w = XtVaCreateManagedWidget("text-field",
  4365.         xmTextFieldWidgetClass, rc, NULL);
  4366.  
  4367.     /* RowColumn is full -- now manage */
  4368.     XtManageChild(rc);
  4369.  
  4370.     /* Set the client data "Ok" and "Cancel" button's callbacks. */
  4371.     action_items[0].data = (caddr_t)text_w;
  4372.     action_items[1].data = (caddr_t)text_w;
  4373.  
  4374.     /* Create the action area -- we don't need the widget it returns. */
  4375.     action_a = CreateActionArea(pane, action_items, XtNumber(action_items));
  4376.  
  4377.     /* callback for Return in TextField.  Use action_a as client data */
  4378.     XtAddCallback(text_w, XmNactivateCallback, activate_cb, action_a);
  4379.  
  4380.     XtManageChild(pane);
  4381.     XtPopup(dialog, XtGrabNone);
  4382. }
  4383.  
  4384. /*--------------*/
  4385. /* The next four functions are the callback routines for the buttons
  4386.  * in the action area for the dialog created above.  Again, they are
  4387.  * simple examples, yet they demonstrate the fundamental design approach.
  4388.  */
  4389. static void
  4390. close_dialog(w, shell)
  4391. Widget w, shell;
  4392. {
  4393.     XtDestroyWidget(shell);
  4394. }
  4395.  
  4396. /* The "ok" button was pushed or the user pressed Return */
  4397. static void
  4398. ok_pushed(w, text_w, cbs)
  4399. Widget w, text_w;         /* the text widget is the client data */
  4400. XmAnyCallbackStruct *cbs;
  4401. {
  4402.     char *text = XmTextFieldGetString(text_w);
  4403.  
  4404.     printf("String = %s0, text);
  4405.     XtFree(text);
  4406. }
  4407.  
  4408. static void
  4409. cancel_pushed(w, text_w, cbs)
  4410. Widget w, text_w;         /* the text field is the client data */
  4411. XmAnyCallbackStruct *cbs;
  4412. {
  4413.     /* cancel the whole operation; reset to NULL. */
  4414.     XmTextFieldSetString(text_w, "");
  4415. }
  4416.  
  4417. static void
  4418. help(w, string)
  4419. Widget w;
  4420. String string;
  4421. {
  4422.     puts(string);
  4423. }
  4424. /*--------------*/
  4425.  
  4426. /* When Return is pressed in TextField widget, respond by getting
  4427.  * the designated "default button" in the action area and activate
  4428.  * it as if the user had selected it.
  4429.  */
  4430. static void
  4431. activate_cb(text_w, client_data, cbs)
  4432. Widget text_w;              /* user pressed Return in this widget */
  4433. XtPointer client_data;        /* action_area passed as client data */
  4434. XmAnyCallbackStruct *cbs;   /* borrow the "event" field from this */
  4435. {
  4436.     Widget dflt, action_area = (Widget)client_data;
  4437.  
  4438.     XtVaGetValues(action_area, XmNdefaultButton, &dflt, NULL);
  4439.     if (dflt) /* sanity check -- this better work */
  4440.         /* make the default button think it got pushed.  This causes
  4441.          * "ok_pushed" to be called, but XtCallActionProc() causes
  4442.          * the button appear to be activated as if the user selected it.
  4443.          */
  4444.         XtCallActionProc(dflt, "ArmAndActivate", cbs->event, NULL, 0);
  4445. }
  4446.  
  4447. #define TIGHTNESS 20
  4448.  
  4449. Widget
  4450. CreateActionArea(parent, actions, num_actions)
  4451. Widget parent;
  4452. ActionAreaItem *actions;
  4453. int num_actions;
  4454. {
  4455.     Widget action_area, widget;
  4456.     int i;
  4457.  
  4458.     action_area = XtVaCreateWidget("action_area", xmFormWidgetClass, parent,
  4459.         XmNfractionBase, TIGHTNESS*num_actions - 1,
  4460.         XmNleftOffset,   10,
  4461.         XmNrightOffset,  10,
  4462.         NULL);
  4463.  
  4464.     for (i = 0; i < num_actions; i++) {
  4465.         widget = XtVaCreateManagedWidget(actions[i].label,
  4466.             xmPushButtonWidgetClass, action_area,
  4467.             XmNleftAttachment,       i? XmATTACH_POSITION : XmATTACH_FORM,
  4468.             XmNleftPosition,         TIGHTNESS*i,
  4469.             XmNtopAttachment,        XmATTACH_FORM,
  4470.             XmNbottomAttachment,     XmATTACH_FORM,
  4471.             XmNrightAttachment,
  4472.                     i != num_actions-1? XmATTACH_POSITION : XmATTACH_FORM,
  4473.             XmNrightPosition,        TIGHTNESS*i + (TIGHTNESS-1),
  4474.             XmNshowAsDefault,        i == 0,
  4475.             XmNdefaultButtonShadowThickness, 1,
  4476.             NULL);
  4477.         if (actions[i].callback)
  4478.             XtAddCallback(widget, XmNactivateCallback,
  4479.                 actions[i].callback, actions[i].data);
  4480.         if (i == 0) {
  4481.             /* Set the action_area's default button to the first widget
  4482.              * created (or, make the index a parameter to the function
  4483.              * or have it be part of the data structure). Also, set the
  4484.              * pane window constraint for max and min heights so this
  4485.              * particular pane in the PanedWindow is not resizable.
  4486.              */
  4487.             Dimension height, h;
  4488.             XtVaGetValues(action_area, XmNmarginHeight, &h, NULL);
  4489.             XtVaGetValues(widget, XmNheight, &height, NULL);
  4490.             height += 2 * h;
  4491.             XtVaSetValues(action_area,
  4492.                 XmNdefaultButton, widget,
  4493.                 XmNpaneMaximum,   height,
  4494.                 XmNpaneMinimum,   height,
  4495.                 NULL);
  4496.         }
  4497.     }
  4498.  
  4499.     XtManageChild(action_area);
  4500.  
  4501.     return action_area;
  4502. }
  4503.  
  4504.  
  4505.  
  4506. -----------------------------------------------------------------------------
  4507. Subject: 139)  How do I create a "busy working cursor"?
  4508.  
  4509. Answer: - in Baudouin's code (following), the idea is to keep in an array an
  4510. up-to-date list of all shells used in the application, and set for all of them
  4511. the cursor to a watch or to the default cursor, with the 2 functions provided.
  4512.  
  4513. - in Dan Heller's code (later), the idea is to turn on the watch cursor for
  4514. the top-level shell only, popup a working window to possibly abort the
  4515. callback, and manage some expose events during the callback.
  4516.  
  4517. - in the FAQ for comp.windows.x (#113), the idea is to bring a large window on
  4518. top of the application, hide all windows below it, and turn on the watch
  4519. cursor on this large window. Unmapping the large window resets the default
  4520. cursor, mapping it turns on the watch cursor.
  4521.  
  4522. From Baudouin Raoult (mab@ecmwf.co.uk)
  4523.  
  4524. void my_SetWatchCursor(w)
  4525. Widget w;
  4526. {
  4527.         static Cursor watch = NULL;
  4528.  
  4529.         if(!watch)
  4530.                 watch = XCreateFontCursor(XtDisplay(w),XC_watch);
  4531.  
  4532.         XDefineCursor(XtDisplay(w),XtWindow(w),watch);
  4533.         XmUpdateDisplay(w);
  4534. }
  4535.  
  4536. void my_ResetCursor(w)
  4537. Widget w;
  4538. {
  4539.         XUndefineCursor(XtDisplay(w),XtWindow(w));
  4540.         XmUpdateDisplay(w);
  4541. }
  4542.  
  4543.  
  4544. Answer: A solution with lots of bells and whistles is
  4545.  
  4546. /* Written by Dan Heller.  Copyright 1991, O'Reilly && Associates.
  4547.  * This program is freely distributable without licensing fees and
  4548.  * is provided without guarantee or warrantee expressed or implied.
  4549.  * This program is -not- in the public domain.
  4550.  */
  4551.  
  4552. /* busy.c -- demonstrate how to use a WorkingDialog and to process
  4553.  * only "important" events.  e.g., those that may interrupt the
  4554.  * task or to repaint widgets for exposure.  Set up a simple shell
  4555.  * and a widget that, when pressed, immediately goes into its own
  4556.  * loop.  First, "lock" the shell so that a timeout cursor is set on
  4557.  * the shell and pop up a WorkingDialog.  Then enter loop ... sleep
  4558.  * for one second ten times, checking between each interval to see
  4559.  * if the user clicked the Stop button or if any widgets need to be
  4560.  * refreshed.  Ignore all other events.
  4561.  *
  4562.  * main() and get_busy() are stubs that would be replaced by a real
  4563.  * application; all other functions can be used "as is."
  4564.  */
  4565. #include <Xm/MessageB.h>
  4566. #include <Xm/PushB.h>
  4567. #include <X11/cursorfont.h>
  4568.  
  4569. Widget shell;
  4570. void TimeoutCursors();
  4571. Boolean CheckForInterrupt();
  4572.  
  4573. main(argc, argv)
  4574. int argc;
  4575. char *argv[];
  4576. {
  4577.     XtAppContext app;
  4578.     Widget button;
  4579.     XmString label;
  4580.     void get_busy();
  4581.  
  4582.     shell = XtVaAppInitialize(&app, "Demos",
  4583.         NULL, 0, &argc, argv, NULL, NULL);
  4584.  
  4585.     label = XmStringCreateSimple(
  4586.         "Boy, is *this* going to take a long time.");
  4587.     button = XtVaCreateManagedWidget("button",
  4588.         xmPushButtonWidgetClass, shell,
  4589.         XmNlabelString,          label,
  4590.         NULL);
  4591.     XmStringFree(label);
  4592.     XtAddCallback(button, XmNactivateCallback, get_busy, argv[1]);
  4593.  
  4594.     XtRealizeWidget(shell);
  4595.     XtAppMainLoop(app);
  4596. }
  4597.  
  4598. void
  4599. get_busy(widget)
  4600. Widget widget;
  4601. {
  4602.     int n;
  4603.  
  4604.     TimeoutCursors(True, True);
  4605.     for (n = 0; n < 10; n++) {
  4606.         sleep(1);
  4607.         if (CheckForInterrupt()) {
  4608.             puts("Interrupt!");
  4609.             break;
  4610.         }
  4611.     }
  4612.     if (n == 10)
  4613.         puts("done.");
  4614.     TimeoutCursors(False, NULL);
  4615. }
  4616.  
  4617. /* The interesting part of the program -- extract and use at will */
  4618. static Boolean stopped;  /* True when user wants to stop processing */
  4619. static Widget dialog;    /* WorkingDialog displayed when timed out */
  4620.  
  4621. /* timeout_cursors() turns on the "watch" cursor over the application
  4622.  * to provide feedback for the user that he's going to be waiting
  4623.  * a while before he can interact with the appliation again.
  4624.  */
  4625. void
  4626. TimeoutCursors(on, interruptable)
  4627. int on, interruptable;
  4628. {
  4629.     static int locked;
  4630.     static Cursor cursor;
  4631.     extern Widget shell;
  4632.     XSetWindowAttributes attrs;
  4633.     Display *dpy = XtDisplay(shell);
  4634.     XEvent event;
  4635.     Arg args[1];
  4636.     XmString str;
  4637.     extern void stop();
  4638.  
  4639.     /* "locked" keeps track if we've already called the function.
  4640.      * This allows recursion and is necessary for most situations.
  4641.      */
  4642.     on? locked++ : locked--;
  4643.     if (locked > 1 || locked == 1 && on == 0)
  4644.         return; /* already locked and we're not unlocking */
  4645.  
  4646.     stopped = False; /* doesn't matter at this point; initialize */
  4647.     if (!cursor) /* make sure the timeout cursor is initialized */
  4648.         cursor = XCreateFontCursor(dpy, XC_watch);
  4649.  
  4650.     /* if "on" is true, then turn on watch cursor, otherwise, return
  4651.      * the shell's cursor to normal.
  4652.      */
  4653.     attrs.cursor = on? cursor : None;
  4654.  
  4655.     /* change the main application shell's cursor to be the timeout
  4656.      * cursor (or to reset it to normal).  If other shells exist in
  4657.      * this application, they will have to be listed here in order
  4658.      * for them to have timeout cursors too.
  4659.      */
  4660.     XChangeWindowAttributes(dpy, XtWindow(shell), CWCursor, &attrs);
  4661.  
  4662.     XFlush(dpy);
  4663.  
  4664.     if (on) {
  4665.         /* we're timing out, put up a WorkingDialog.  If the process
  4666.          * is interruptable, allow a "Stop" button.  Otherwise, remove
  4667.          * all actions so the user can't stop the processing.
  4668.          */
  4669.         str = XmStringCreateSimple("Busy.  Please Wait.");
  4670.         XtSetArg(args[0], XmNmessageString, str);
  4671.         dialog = XmCreateWorkingDialog(shell, "Busy", args, 1);
  4672.         XmStringFree(str);
  4673.         XtUnmanageChild(
  4674.             XmMessageBoxGetChild(dialog, XmDIALOG_OK_BUTTON));
  4675.         if (interruptable) {
  4676.             str = XmStringCreateSimple("Stop");
  4677.             XtVaSetValues(dialog, XmNcancelLabelString, str, NULL);
  4678.             XmStringFree(str);
  4679.             XtAddCallback(dialog, XmNcancelCallback, stop, NULL);
  4680.         } else
  4681.             XtUnmanageChild(
  4682.                 XmMessageBoxGetChild(dialog, XmDIALOG_CANCEL_BUTTON));
  4683.         XtUnmanageChild(
  4684.             XmMessageBoxGetChild(dialog, XmDIALOG_HELP_BUTTON));
  4685.         XtManageChild(dialog);
  4686.     } else {
  4687.         /* get rid of all button and keyboard events that occured
  4688.          * during the time out.  The user shouldn't have done anything
  4689.          * during this time, so flush for button and keypress events.
  4690.          * KeyRelease events are not discarded because accelerators
  4691.          * require the corresponding release event before normal input
  4692.          * can continue.
  4693.          */
  4694.         while (XCheckMaskEvent(dpy,
  4695.                 ButtonPressMask | ButtonReleaseMask | ButtonMotionMask
  4696.                 | PointerMotionMask | KeyPressMask, &event)) {
  4697.             /* do nothing */;
  4698.         }
  4699.         XtDestroyWidget(dialog);
  4700.     }
  4701. }
  4702.  
  4703. /* User Pressed the "Stop" button in dialog. */
  4704. void
  4705. stop(dialog)
  4706. Widget dialog;
  4707. {
  4708.     stopped = True;
  4709. }
  4710.  
  4711. Boolean
  4712. CheckForInterrupt()
  4713. {
  4714.     extern Widget shell;
  4715.     Display *dpy = XtDisplay(shell);
  4716.     Window win = XtWindow(dialog);
  4717.     XEvent event;
  4718.  
  4719.     /* Make sure all our requests get to the server */
  4720.     XFlush(dpy);
  4721.  
  4722.     /* Let motif process all pending exposure events for us. */
  4723.     XmUpdateDisplay(shell);
  4724.  
  4725.     /* Check the event loop for events in the dialog ("Stop"?) */
  4726.     while (XCheckMaskEvent(dpy,
  4727.             ButtonPressMask | ButtonReleaseMask | ButtonMotionMask |
  4728.             PointerMotionMask | KeyPressMask | KeyReleaseMask,
  4729.             &event)) {
  4730.         /* got an "interesting" event. */
  4731.         if (event.xany.window == win)
  4732.             XtDispatchEvent(&event); /* it's in our dialog.. */
  4733.         else /* uninteresting event--throw it away and sound bell */
  4734.             XBell(dpy, 50);
  4735.     }
  4736.     return stopped;
  4737. }
  4738.  
  4739.  
  4740. -----------------------------------------------------------------------------
  4741. Subject: 140)  What order should the libraries be linked in?
  4742. [Last modified: August 92]
  4743.  
  4744. Answer: At link time, use the library order  -lXm -lXt -lX11. There are two
  4745. reasons for this (dbrooks@osf.org):
  4746.  
  4747. On most systems, the order matters because the linker won't re-scan a library
  4748. once it is done with it.  Thus any references to Xlib calls from Xm will
  4749. probably be unresolved.
  4750.  
  4751. The [other] problem is that there are two VendorShell widgets. A dummy is
  4752. provided in the Xt library, but a widget set will rely on its own being
  4753. referenced.  If you mention Xt first, the linker will choose the wrong one.
  4754.  
  4755. Motif code will wrongly assume the Motif VendorShell has been class-
  4756. initialized [and will probably crash].
  4757.  Xaw has a similar problem, but a softer landing; it only complains about
  4758. unregistered converters.
  4759.  
  4760.  
  4761. -----------------------------------------------------------------------------
  4762. Subject: 141)  How do I use xmkmf for Motif clients?
  4763.  
  4764. [Last modified: October 1992]
  4765.  
  4766. Answer: This advice comes from dbrooks@osf.org:
  4767.  
  4768. There are a number of intractable problems with using X configuration files
  4769. and xmkmf, while trying to make it easy to build Motif.  Not the least of
  4770. these, but one I've never heard mentioned yet, is that the rules for
  4771. contructing the names of shared library macros are machine-dependent, and in
  4772. the various xxxLib.tmpl files.  Do we edit all those files to add definitions
  4773. for XMLIB, DEPXMLIB, etc., or do we put a maze of #ifdefs into the Motif.tmpl
  4774. file?
  4775.  
  4776. Please note that, if you install Motif, it overwrites your installed
  4777. Imake.tmpl with one that includes Motif.tmpl and Motif.rules.
  4778.  
  4779. With those caveats, I think the following guidelines will help.
  4780.  
  4781. David Brooks OSF
  4782.  
  4783. Clients in the X11R5 release use the xmkmf command to build Makefiles.  In
  4784. general, the xmkmf command cannot be used for Motif clients, because of the
  4785. need to consider the UseInstalledMotif flag separately.  Since xmkmf is a
  4786. simple script that calls imake, it is easy to construct the proper call to
  4787. imake using the following rules.
  4788.  
  4789. In the following, replace {MTOP} by the toplevel directory with the Motif
  4790. source tree, and {XTOP} by the toplevel ("mit") directory with the X source.
  4791. It is assumed that the directory containing your installed imake is in your
  4792. PATH.
  4793.  
  4794. When needed, the imake variables XTop and MTop are normally set in your
  4795. site.def (to {XTOP} amd {MTOP} respectively); however they may also be set
  4796. with additional -D arguments to imake.
  4797.  
  4798. 1. With both X and Motif in their source trees, ensure the imake variables
  4799.    XTop and MTop are set, and use:
  4800.  
  4801.         ${XTOP}/config/imake -I{MTOP}/config
  4802.  
  4803. 2. With Motif in its source tree, and X installed, ensure MTop is set, and
  4804.    use:
  4805.  
  4806.         imake -I{MTOP}/config -DUseInstalled
  4807.  
  4808. 3. With both Motif and X installed, and a nonstandard ProjectRoot (see
  4809.    site.def for an explanation of this), use:
  4810.  
  4811.         imake -DUseInstalled -DUseInstalledMotif -I{ProjectRoot}/lib/X11/config
  4812.  
  4813.    or, if the configuration files are in /usr/lib/X11/config:
  4814.  
  4815.         imake -DUseInstalled -DUseInstalledMotif
  4816.  
  4817.  
  4818. To build a simple Imakefile, remember to include lines like this:
  4819.  
  4820.         LOCAL_LIBRARIES = XmClientLibs
  4821.                 DEPLIBS = XmClientDepLibs
  4822.  
  4823. Or, for a client that uses uil/mrm, replace these by MrmClientLibs and
  4824. MrmClientDepLibs, and also use:
  4825.  
  4826.         MSimpleUilTarget(program)
  4827.  
  4828. to build the client and uid file.  Look at the demos for more examples.
  4829.  
  4830.  
  4831. And Paul Howell <grue@engin.umich.edu> added:
  4832.  
  4833. i did this, calling the new script "xmmkmf".  It passes both -DUseInstalled
  4834. and -DUseInstalledMotif.
  4835.  
  4836. and i modified the stock R5 Imake.tmpl to do this:
  4837.  
  4838. #include <Project.tmpl>
  4839. #ifdef UseInstalledMotif
  4840. #include <Motif.tmpl>
  4841. #endif
  4842.  
  4843. #include <Imake.rules>
  4844. #ifdef UseInstalledMotif
  4845. #include <Motif.rules>
  4846. #endif
  4847.  
  4848. the result was something that does both athena and motif rules.  and it really
  4849. works, just that easy!
  4850.  
  4851.  
  4852. -----------------------------------------------------------------------------
  4853. Subject: 142)  How do I make context sensitive help?  The Motif Style Guide
  4854. says that an application must initiate context-sensitive help by changing the
  4855. shape of the pointer to the question pointer. When the user moves the pointer
  4856. to the component help is wanted on and presses BSelect, any available context
  4857. sensitive help for the component must be presented, and the pointer reverts
  4858. from the question pointer.
  4859. [Last modified: August 92]
  4860.  
  4861. Answer: A widget that gives context sensitive help would place this help in
  4862. the XmNhelpCallback function. To trigger this function: (from Martin G C
  4863. Davies, mgcd@se.alcbel.be)
  4864.  
  4865. I use the following callback that is called when the "On Context" help
  4866. pulldown menu is selected. It does the arrow bit and calls the help callbacks
  4867. for the widget. It also zips up the widget tree looking for help if needs be.
  4868. I don't restrict the arrows motion so I can get help on dialog boxes. No
  4869. prizes for guessing what "popup_message" does.
  4870.  
  4871.  
  4872. static void ContextHelp(
  4873.     Widget              w ,
  4874.     Opaque              * tag ,
  4875.     XmAnyCallbackStruct * callback_struct
  4876. )
  4877. {
  4878.     static Cursor   context_cursor = NULL ;
  4879.     Widget          context_widget ;
  4880.  
  4881.     if ( context_cursor == NULL )
  4882.         context_cursor = XCreateFontCursor( display, XC_question_arrow ) ;
  4883.  
  4884.     context_widget = XmTrackingLocate( top_level_widget,
  4885.                                 context_cursor, FALSE ) ;
  4886.  
  4887.     if ( context_widget != NULL ) /* otherwise its not a widget */
  4888.     {
  4889.         XmAnyCallbackStruct cb ;
  4890.  
  4891.         cb.reason = XmCR_HELP ;
  4892.         cb.event = callback_struct->event ;
  4893.  
  4894.         /*
  4895.          * If there's no help at this widget we'll track back
  4896.            up the hierarchy trying to find some.
  4897.          */
  4898.  
  4899.         do
  4900.         {
  4901.             if ( ( XtHasCallbacks( context_widget, XmNhelpCallback ) ==
  4902.                                                 XtCallbackHasSome ) )
  4903.             {
  4904.                 XtCallCallbacks( context_widget, XmNhelpCallback, & cb ) ;
  4905.                 return ;
  4906.             }
  4907.             else
  4908.                 context_widget = XtParent( context_widget ) ;
  4909.         } while ( context_widget != NULL ) ;
  4910.     }
  4911.  
  4912.     popup_message( "No context-sensitive help found\n\
  4913. for the selected object." ) ;
  4914. }
  4915.  
  4916.  
  4917.  
  4918. Dave Bonnett suggested, to use the following translations for XmText (and
  4919. XmTextField) widgets to get the same help with key strokes, and to provide an
  4920. accelerator label in the Context help menu entry.
  4921.  
  4922. MyApp*XmText*translations: #override\n\
  4923.                                 <Key>F1:    Help()
  4924.  
  4925. MyApp*Help_menu*Contextual Help.acceleratorText:   F1
  4926.  
  4927. MyApp*defaultVirtualBindings:           osfBackSpace : <Key>Delete\n\
  4928.                                         osfRight : <Key>Right\n\
  4929.                                         osfLeft  : <Key>Left\n\
  4930.                                         osfUp    : <Key>Up\n\
  4931.                                         osfHelp  : <Key>F1\n\
  4932.                                         osfDown  : <Key>Down
  4933.  
  4934. -----------------------------------------------------------------------------
  4935. Subject: 143) TOPIC: ACKNOWLEDGEMENTS
  4936.  
  4937. This list was compiled using questions and answers posed to
  4938. comp.windows.x.motif and motif-talk. Some extracts were also taken from FAQs
  4939. of comp.windows.x.  To all who contributed one way or the other, thanks! I
  4940. haven't often given individual references, but  you may recognise
  4941. contributions. If I have mangled them too much, let me know.
  4942.  
  4943.  
  4944.  
  4945. That's all folks!
  4946.  
  4947.  
  4948. +----------------------+---+
  4949.   Jan Newmarch, Information Science and Engineering,
  4950.   University of Canberra, PO Box 1, Belconnen, Act 2616
  4951.   Australia. Tel: (Aust) 6-2522422. Fax: (Aust) 6-2522999
  4952.  
  4953.   ACSnet: jan@ise.canberra.edu.au
  4954.   ARPA:   jan%ise.canberra.edu.au@uunet.uu.net
  4955.   UUCP:   {uunet,ukc}!munnari!ise.canberra.edu.au!jan
  4956.   JANET:  jan%au.edu.canberra.ise@EAN-RELAY
  4957.  
  4958. +--------------------------+
  4959.  
  4960.  
  4961.  
  4962.  
  4963.  
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977.  
  4978.  
  4979.  
  4980.  
  4981.  
  4982.  
  4983.  
  4984.  
  4985.  
  4986.  
  4987.  
  4988.  
  4989.  
  4990.  
  4991.  
  4992.  
  4993.  
  4994.  
  4995.  
  4996.  
  4997.  
  4998.  
  4999.  
  5000.  
  5001.  
  5002.  
  5003.  
  5004.  
  5005.  
  5006.  
  5007.  
  5008.  
  5009.  
  5010.  
  5011.  
  5012.  
  5013.  
  5014.  
  5015.  
  5016.  
  5017.  
  5018.  
  5019.  
  5020.  
  5021.  
  5022.  
  5023.  
  5024.  
  5025.  
  5026.  
  5027.  
  5028.  
  5029.  
  5030.  
  5031.  
  5032.  
  5033.  
  5034.  
  5035.  
  5036.  
  5037.  
  5038.  
  5039.  
  5040.  
  5041.  
  5042.  
  5043.  
  5044.  
  5045.  
  5046.  
  5047.  
  5048.  
  5049.  
  5050.  
  5051.  
  5052.  
  5053.  
  5054.  
  5055.  
  5056.  
  5057.  
  5058.  
  5059.  
  5060.  
  5061.  
  5062.  
  5063.  
  5064.  
  5065.  
  5066.  
  5067.  
  5068.  
  5069.  
  5070.  
  5071.  
  5072.  
  5073.  
  5074.  
  5075.  
  5076.  
  5077.  
  5078.  
  5079.  
  5080.  
  5081.  
  5082.  
  5083.  
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099.  
  5100.  
  5101.  
  5102.  
  5103.  
  5104.  
  5105.  
  5106.  
  5107.  
  5108.  
  5109.  
  5110.  
  5111.  
  5112.  
  5113.  
  5114.  
  5115.  
  5116.  
  5117.  
  5118.  
  5119.  
  5120.  
  5121.  
  5122.  
  5123.  
  5124.  
  5125.  
  5126.  
  5127.  
  5128.  
  5129.  
  5130.  
  5131.  
  5132.  
  5133.  
  5134.  
  5135.  
  5136.  
  5137.  
  5138.  
  5139.  
  5140.  
  5141.  
  5142.  
  5143.  
  5144.  
  5145.  
  5146.  
  5147.  
  5148.  
  5149.  
  5150.  
  5151.  
  5152.  
  5153.  
  5154.  
  5155.  
  5156.  
  5157.  
  5158.  
  5159.  
  5160.  
  5161.  
  5162.  
  5163.  
  5164.  
  5165.  
  5166.  
  5167.  
  5168.  
  5169.  
  5170.  
  5171.  
  5172.  
  5173.  
  5174.  
  5175.  
  5176.  
  5177.  
  5178.  
  5179.  
  5180.  
  5181.  
  5182.  
  5183.  
  5184.  
  5185.  
  5186.  
  5187.  
  5188.  
  5189.  
  5190.  
  5191.  
  5192.  
  5193.  
  5194.  
  5195.  
  5196.  
  5197.  
  5198.  
  5199.  
  5200.  
  5201.  
  5202.  
  5203.  
  5204.  
  5205.  
  5206.  
  5207.  
  5208.  
  5209.  
  5210.  
  5211.  
  5212.  
  5213.  
  5214.  
  5215.  
  5216.  
  5217.  
  5218.  
  5219.  
  5220.  
  5221.  
  5222.  
  5223.  
  5224.  
  5225.  
  5226.  
  5227.  
  5228.  
  5229.  
  5230.  
  5231.  
  5232.  
  5233.  
  5234.  
  5235.  
  5236.  
  5237.  
  5238.  
  5239.  
  5240.  
  5241.  
  5242.  
  5243.  
  5244.  
  5245.  
  5246.  
  5247.  
  5248.  
  5249.  
  5250.  
  5251.  
  5252.  
  5253.  
  5254.  
  5255.  
  5256.  
  5257.  
  5258.  
  5259.  
  5260.  
  5261.  
  5262.  
  5263.  
  5264.  
  5265.  
  5266.  
  5267.  
  5268.  
  5269.  
  5270.  
  5271.  
  5272.  
  5273.  
  5274.  
  5275.  
  5276.  
  5277.  
  5278.  
  5279.  
  5280.  
  5281.  
  5282.  
  5283.  
  5284.  
  5285.  
  5286.  
  5287.  
  5288.  
  5289.  
  5290.  
  5291.  
  5292.  
  5293.  
  5294.  
  5295.  
  5296.  
  5297.  
  5298.  
  5299.  
  5300.  
  5301.  
  5302.  
  5303.  
  5304.  
  5305.  
  5306.  
  5307.  
  5308.  
  5309.  
  5310.  
  5311.  
  5312.  
  5313.  
  5314.  
  5315.  
  5316.  
  5317.  
  5318.  
  5319.  
  5320.  
  5321.  
  5322.  
  5323.  
  5324.  
  5325.  
  5326.  
  5327.  
  5328.  
  5329.  
  5330.  
  5331.  
  5332.  
  5333.  
  5334.  
  5335.  
  5336.  
  5337.  
  5338.  
  5339.  
  5340.  
  5341.  
  5342.  
  5343.  
  5344.  
  5345.  
  5346.  
  5347.  
  5348.  
  5349.  
  5350.  
  5351.  
  5352.  
  5353.  
  5354.  
  5355.  
  5356.  
  5357.  
  5358.  
  5359.  
  5360.  
  5361.  
  5362.  
  5363.  
  5364.  
  5365.  
  5366.  
  5367.  
  5368.  
  5369.  
  5370.  
  5371.  
  5372.  
  5373.  
  5374.  
  5375.  
  5376.  
  5377.  
  5378.  
  5379.  
  5380.  
  5381.  
  5382.  
  5383.  
  5384.  
  5385.  
  5386.  
  5387.  
  5388.  
  5389.  
  5390.  
  5391.  
  5392.  
  5393.  
  5394.  
  5395.  
  5396.  
  5397.  
  5398.  
  5399.  
  5400.  
  5401.  
  5402.  
  5403.  
  5404.  
  5405.  
  5406.  
  5407.  
  5408.  
  5409.  
  5410.  
  5411.  
  5412.  
  5413.  
  5414.  
  5415.  
  5416.  
  5417.  
  5418.  
  5419.  
  5420.  
  5421.  
  5422.  
  5423.  
  5424.  
  5425.  
  5426.  
  5427.  
  5428.  
  5429.  
  5430.  
  5431.  
  5432.  
  5433.  
  5434.  
  5435.  
  5436.  
  5437.  
  5438.  
  5439.  
  5440.  
  5441.  
  5442.  
  5443. Local Variables:
  5444. mode: outline
  5445. outline-regexp: "Subject: +[0-9]+)"
  5446. eval: (hide-body)
  5447. End:
  5448.